Re: error page problem

From: Willy Tarreau <w#1wt.eu>
Date: Thu, 15 Apr 2010 07:29:47 +0200


On Tue, Apr 13, 2010 at 05:23:20PM +0200, Holger Just wrote:
> Hi Miko??aj,
>
> On 2010-04-13 12:47, Miko??aj Radzewicz wrote:
> > I was trying to configure custom error pages on haproxy but after
> > waisting a lot of time I'm not successful. I wanted to serve it all
> > the time as my backends give it to the clients.
>
> if I understand you correct you want to check if one of your backends
> returned a HTTP 500 and replace its response to the client with the
> errorfile in haproxy.
>
> This is actually not possible. The errorfile and errorloc parameters
> only apply for error generated by Haproxy itself. So the file specified
> in errorfile 500 ... is only served if Haproxy itself had an internal
> error. You have to fix your application error pages instead.

Well, there's an ugly hack which can be used as a workaround. When an "rspdeny" rule is matched, haproxy emits an HTTP 502 response (bad gateway). You can then use that to deny an HTTP 500 response and write your own 502 error response. You must just keep in mind that it will also be returned when a server crashes while processing a request, but that may be what you want. In short :

    rspdeny ^HTTP/1..\ 500
    errorfile 502 /etc/haproxy/error502.http

Regards,
Willy Received on 2010/04/15 07:29

This archive was generated by hypermail 2.2.0 : 2010/04/15 07:45 CEST