Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

What about redirect or redir

A simple redir example

server srv1 redir check

redirect can be set in all by defaults option.

share|improve this answer

The backup keyword is what we use for this. See this example:

listen example_com
option httpchk OPTIONS * HTTP/1.1\r\nHost:\\r\nUser-Agent:\ HAProxy
server  web01 cookie cookie_web01 check inter 5000 rise 2 fall 5 disabled
server  web02 cookie cookie_web02 check inter 5000 rise 2 fall 5 disabled
server  prx  backup

Here both servers web01 and web02 are set to disabled, in which case the backup server prx on will be used, which serves a maintenance page. The prx server in our case is the HAProxy server itself and on port 9000 runs an Apache HTTPD, serving the maintenance content:

<VirtualHost *:9000>

    DocumentRoot /var/www/
    <Directory /var/www/>
        Options -Indexes

    RewriteEngine On
    RewriteCond %{DOCUMENT_ROOT}/systemDown.html -f
    RewriteCond %{SCRIPT_FILENAME} !systemDown.html
    RewriteRule ^.*$ /systemDown.html [R=503,L]
    ErrorDocument 503 /systemDown.html

share|improve this answer
Thanks, I'll look into this. – UpTheCreek Mar 13 '13 at 7:29

This blog post helped me:

It suggests setting/customizing the 503 error handler:

errorfile 503 /var/www/503maintance.html

Note: you need to include the http headers in the error handler file:

HTTP/1.0 503 Service Unavailable
Cache-Control: no-cache
Connection: close
Content-Type: text/html
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.