Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

502 Proxy Errors between IIS and Apache2

I am currently running apache2 on a SUSE instance @EC2. As part of my site, my data uses mod_proxy to hit a REST server running IIS via Proxy/ReverseProxy.

After setting up my vhosts, enabling mod_proxy and establishing my config, I found that I was frequently encountering 502 errors. These errors were of the Proxy Error and Bad Gateway flavour. After doing some considerable google, I found that there was a difference in the way IIS and apache terminate their connections which was causing the error. After setting the following environment variables, performance has improved markedly:

SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
SetEnv proxy-initial-not-pooled 1

What I'm wondering is why this works and what an ideal configuration would look like.

Is my understanding that, with the Env variables:
I am forcing an HTTP 1.0 request (which will standardize the termination expectaions)
NOT keeping alive any connections
NOT using any pooled connections
correct?

What if I need to use pooled connections? What if I want to use keep-alives? In short, I'm looking for best practices to replace the toothpick and glue solution I'm currently using

like image 509
user1026361 Avatar asked Sep 06 '12 15:09

user1026361


1 Answers

I see this question has been around for a while, so I thought I would throw in my 2 cents. More of my experience anyways...

As far as I am aware those three env variables or settings are ok in production. Your understanding of them is correct also. When I had this problem way back I found this link to be usefull in the explaination of the problem. It only occurrs with IIS in the backend.... Just note that the intial pooled setting will impact performance expecially in Http/1.0 clients... I have never noticed anything, however, the iis server alone has 64gb of ram and several cores on the machine... so I admit I can't be sure that 'it does not impact at all', all I know is that 'with enough resources you don't have a problem'...

To be honest but, re your toothpick statement, I know of dozens of production environments that implement this... You can set other things and play around with apache and change it to implement longer timeouts etc, but I have set these settings and it just works...

I guess I just wanted to say that you shouldn't loose any sleep over these settings. In my opinion, whilst I don't know if they are best practices, they are safe...

Sorry I can't help more...

Cheers Robin

like image 164
Robin Rieger Avatar answered Oct 16 '22 17:10

Robin Rieger