I would like haproxy to use its own 503 document page when back server (backend) sends HTTP 503 code. Is it possible?
Have seen something like "monitor fail" conditions but don't know how to add it to the frontend.
I would like haproxy to use its own 503 document page when back server (backend) sends HTTP 503 code. Is it possible?
Have seen something like "monitor fail" conditions but don't know how to add it to the frontend.
You can use the
errorfile
directive and then a custom.http
text file. So for example:Content of the file would then be something like:
The
errorfile
directive can be specific to a backend as well.The "errorfile" setting cannot be used to change a response sent by HAProxy if nodes are online. This setting only affects HAProxy when all nodes are offline.
There is something dirty you can do. You can block responses 503, which will result in returning the custom 502 error for which you can build an error page. However, keep in mind that any reason haproxy would have to return a 502 (invalid response) will return the same thing.
Basically it's as simple as "rspdeny ^HTTP/1.1 503" combined with "errorfile 502".
We have a portion of our website running on a legacy system, and I ended up using the following:
Hope it helps (even if it is 8 months later).