1

My use case is as follows: In the config I have one frontend that listens on HTTPS and serves to a backend The backend has one or more servers. When all of the backend servers are down, I want to serve a sorry page, hosted in another place to give some info of the outage.

My first attempt was to put the sorry server in the same backend as the regular servers, but with a check backup option. This failed since the host header for the health checks cannot be different per server.

I assume that I need to add a separate backend section for the sorry server, so that I can configure the correct health checks and all, but how do I configure the frontend to switch over to the sorry backend if the regular backend is down?

HA-Proxy version 1.9.16-1ppa1~bionic

Johnathan
  • 111

1 Answers1

0

You can use nbsrv
https://cbonte.github.io/haproxy-dconv/2.2/configuration.html#7.3.1-nbsrv

It can be used this way:

frontend https
    bind (...)
    acl backend_up_foo nbsrv(foo) -m int gt 0
    use_backend foo if backend_up_foo
    default_backend sorry

backend foo (...)

backend sorry http-request set-header Host sorry.example.org (...)

To display sorry page without redirecting users i also use rewrites in Apache, which serves the "sorry page":

<Directory "/path/to/sorry/page">
   RewriteEngine on
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^(.*) index.html
(...)
</Directory>

If the "sorry page" has images or other files they can be put in that directory and RewriteCond will cause Apache to serve them properly. All other URLs are redirected internally in Apache to the actual "sorry page".