HAProxy change 503 page with a custom

February 21, 2015 5k views

Hello, im testing HAProxy to see what i can build with it. After shuting down all my nodes i noticed the ugly 503 page which tells me that there is no servers available. Is it possible to change this page? I cant find where its located

1 Answer

In your HAProxy configuration, you can set a custom errorfile Checkout the HAProxy docs:

The files are returned verbatim on the TCP socket. This allows any trick such
as redirections to another URL or site, as well as tricks to clean cookies,
force enable or disable caching, etc... The package provides default error
files returning the same contents as default errors.

The format is:

errorfile 503 /etc/haproxy/errorfiles/503sorry.http

And you'd want the file to be something like:

HTTP/1.0 503 Service Unavailable
Cache-Control: no-cache
Connection: close
Content-Type: text/html

    <title>403 -  Service Unavailable</title>
          <h2 >Sorry. We're not here right now.</h2>
Have another answer? Share your knowledge.