Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

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

listen example_com 0.0.0.0:8001
...
option httpchk OPTIONS * HTTP/1.1\r\nHost:\ www.example.com\r\nUser-Agent:\ HAProxy
server  web01 10.1.31.21:80 cookie cookie_web01 check inter 5000 rise 2 fall 5 disabled
server  web02 10.1.31.22:80 cookie cookie_web02 check inter 5000 rise 2 fall 5 disabled
server  prx   10.1.31.10:9000  backup

Here both servers web01 and web02 are set to disabled, in which case the backup server prx on 10.1.31.10:9000 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>
    ServerName  example.com
    ServerAdmin webmaster@example.com

    DocumentRoot /var/www/example.com/errors/
    <Directory /var/www/example.com/errors/>
        Options -Indexes
    </Directory>

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

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

What about redirect or redir

A simple redir example

server srv1 10.0.0.10:80 redir http://maintenance.domain.com check

redirect can be set in all by defaults option.

share|improve this answer

Your Answer

 
discard

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.