Is there an easy way to dissable All backends in haproxy, and instead serve an appropriate maintenance page (for http requests)?
I've read a little about the dissabled option, which I understand is per-server, but am wondering if there is a way to simply stop traffic to all backends?
The
backup
keyword is what we use for this. See this example:Here both servers
web01
andweb02
are set todisabled
, in which case thebackup
serverprx
on 10.1.31.10:9000 will be used, which serves a maintenance page. Theprx
server in our case is the HAProxy server itself and on port 9000 runs an Apache HTTPD, serving the maintenance content:This blog post helped me: https://rimuhosting.com/knowledgebase/creating-a-maintenance-page-for-your-site
It suggests setting/customizing the 503 error handler:
Note: you need to include the http headers in the error handler file:
What about redirect or redir
A simple redir example
redirect can be set in all by defaults option.
You may specify a back-end without a server directive and just an 503 error page.
The only thing you'll need to do is (temporary) change the
default_backend
option, or you can create aacl
: