HAProxy Maint Mode Page



  • Using the HAProxy dashboard widget to put servers into maintenance mode.

    When doing so, browsers show a "This site can't be reached".

    If I remember correctly, this used to show 503 error and something about maintenance mode.

    I see in Services/HAProxy/Files an ExampleErrorFile which looks to be what I am after... How do I enable this?

    Name: ExampleErrorFile
    Type: Errorfile
    content:

    HTTP/1.0 503 Service Unavailable
    Cache-Control: no-cache
    Connection: close
    Content-Type: text/html
    
    <html> 
      <head>
        <title>Sorry the webserver you are trying to contact is currently not available.</title>
      </head> 
      <body style="font-family:Arial,Helvetica,sans-serif;">
        <div style="margin: 0 auto; width: 960px;"> 
              <h2>Sorry the webserver you are trying to contact is currently not available.</h2>
        </div>
    The error returned is [<i>{errorcode} {errormsg}</i>] please try again later.
      </body> 
    </html>
    


  • @brailyn
    Configure the 'error file' in the frontend or backend where you want it to show up. And make sure its using mode http. Haproxy does not return the error file in a tcp frontend.



  • Frontend is type ssl/https... When I set error code to 503 and the Error Page to the example, nothing happens.

    Also tried the same thing on one of the backends and same issue. Any ideas what I might be missing?



  • @brailyn
    Well.. ssl/https uses 'mode tcp'. And haproxy will not send the errorfile in that case.
    To make haproxy respond with a http error response, you would need it to 'offload' the ssl traffic with a certificate. Or if you can supply haproxy with the certificate you could still pass the main traffic as-is with the sni frontend and send it to a second 'local frontend' that does the decryption of the https request if a backend is down to serve the error reply.. Together with a nbsrv acl to switch to that second 'error frontend' if the webserver is down.