FlevasGR
By:
FlevasGR

HAProxy change 503 page with a custom

February 21, 2015 13.9k 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

2 Answers

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..

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..

Have another answer? Share your knowledge.