Re: Changing HA Proxy return codes
On 7 April 2010 13:44, Holger Just wrote: > Hi Matt, > > On 2010-04-07 14:34, Matt wrote: > > If I wanted to change the error return code submitted by haproxy (not > > the backend server) is this possible? i.e. change haproxy to return a > > 502 when it's going to return a 504? > > You could (ab)use the errorfile parameter and have haproxy send > arbitrary data. Thus you could do something like this: > > errorfile 500 /etc/haproxy/errorfiles/503.http > errorfile 502 /etc/haproxy/errorfiles/503.http > errorfile 503 /etc/haproxy/errorfiles/503.http > errorfile 504 /etc/haproxy/errorfiles/503.http > > and then have the file at /etc/haproxy/errorfiles/503.http contain > something like this: > > HTTP/1.0 503 Service Unavailable > Cache-Control: no-cache > Connection: close > Content-Type: text/html > Content-Length: 329 > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";> > http://www.w3.org/1999/xhtml";> > > > Something is wrong > > Something went wrong > > > Note that you should correctly re-calculate the Content-Length header > (or leave it out) if you do any changes here. > > Cheers, don't know how I missed that in the manual. Matt
Re: Changing HA Proxy return codes
Hi Matt, On 2010-04-07 14:34, Matt wrote: > If I wanted to change the error return code submitted by haproxy (not > the backend server) is this possible? i.e. change haproxy to return a > 502 when it's going to return a 504? You could (ab)use the errorfile parameter and have haproxy send arbitrary data. Thus you could do something like this: errorfile 500 /etc/haproxy/errorfiles/503.http errorfile 502 /etc/haproxy/errorfiles/503.http errorfile 503 /etc/haproxy/errorfiles/503.http errorfile 504 /etc/haproxy/errorfiles/503.http and then have the file at /etc/haproxy/errorfiles/503.http contain something like this: HTTP/1.0 503 Service Unavailable Cache-Control: no-cache Connection: close Content-Type: text/html Content-Length: 329 http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";> http://www.w3.org/1999/xhtml";> Something is wrong Something went wrong Note that you should correctly re-calculate the Content-Length header (or leave it out) if you do any changes here. --Holger
Changing HA Proxy return codes
I'm guessing the answer is no as i'm unable to find anything in the documentation that suggests otherwise, but.. If I wanted to change the error return code submitted by haproxy (not the backend server) is this possible? i.e. change haproxy to return a 502 when it's going to return a 504? I know the current return codes are correct as of http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html - I could just do with this short hack. Thanks, Matt