Hey Bryan, 

I did check Cherrypy response by directly posting the same request via curl
and it looks ok to me. 

A few interesting things are:
1. haproxy logs the response as 401 correctly - its apache which is calling
haproxy marks it 502
2. It's a post request
3. Even via haproxy, it works when posting smaller files, but get the bad
proxy error when posting a bigger file like 1.5MB+ file

Thanks
Sachin

-----Original Message-----
From: Cassidy, Bryan [mailto:bcass...@winnipeg.ca] 
Sent: Tuesday, June 14, 2011 12:19 AM
To: Sachin Shetty; haproxy@formilux.org
Subject: RE: Apache translates 500 to 502 from haproxy

Hello,

Check that Cherrypy is serving up valid HTTP. You could also try setting
HAProxy to balance in TCP mode instead of HTTP mode, though if this helps it
would just be masking any problem that might exist.

I once had a backend "500" response translated to 502 by HAProxy balancing
in HTTP mode. I wrote 500 in quotes because the backend (Apache improperly
configured in my case) served up an HTML document containing the words "500
internal server error", but didn't actually serve up any HTTP headers prior
to the document - just the document itself. HAProxy then changed the
response to a 502, as it should, because not including headers is obviously
invalid HTTP. I was totally stumped until I ran tcpdump and saw what was
happening.

Your setup is different than mine was, of course. But maybe this will give
you a lead...

Hope this helps,
Bryan

-----Original Message-----
From: Sachin Shetty [mailto:sshe...@egnyte.com] 
Sent: Monday, June 13, 2011 11:12 AM
To: haproxy@formilux.org
Subject: Re: Apache translates 500 to 502 from haproxy

Willy Tarreau <w <at> 1wt.eu> writes:

> 
> On Fri, Jun 10, 2011 at 04:41:08PM +0530, Manoj Kumar wrote:
> > Hi,
> > 
> > We are forwarding specific requests from apache to haproxy which 
> > interbally forwards it to a pool of cherry py servers. We have seen 
> > that certain requests end up in 500 in haproxy and cherry py logs 
> > which is ok and understood, but apache instead sends a 502 to the
client.
> 
> Maybe for any reason apache is rejecting the response and aborting the 
> connection, which might explain that message in your logs :
> 
> > [Fri Jun 10 00:46:01 2011] [error] (103)Software caused connection
> > abort: proxy: pass request body failed to 192.168.2.100:9910 
> > <http://192.168.2.15:9910/>  (192.168.2.15)
> 
> Willy
> 
> 


Hi Willy,

I spent some more time looking in to this, notice the error in apache log,
it is parsing request body and not response

I think this is what is gong on:

1. Apache receives a POST request
2. Forwards to haproxy
3. haproxy forwards to Cherrypy
4. Cherrypy aborts the request due to some internal error, returns 401/500
5. haproxy sends the response back to Apache and terminates the connection
6. Apache however is still expecting somebody will read the posted response
and barfs with pass request body failed error

Now this is definitely due to haproxy, since if I skip haproxy and make
Apache hit cherrypy directly, I see a proper response code from Apache. I
think haproxy is terminating the connection prematurely when the backend
server returns and error status code



Any idea?




Reply via email to