Question

HAProxy change 503 page with a custom

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


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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

<html> 
  <head>
    <title>403 -  Service Unavailable</title>
  </head> 
  <body>
    <div> 
          <h2 >Sorry. We're not here right now.</h2>
    </div>
  </body> 
</html>

I tried setting this up here is my configuration. frontend incoming-https default_backend bad_backend

backend bad_backend mode http errorfile 403 /etc/haproxy/errors/403.http

It redirects to 503 server not found. Not working as expected, please help…