Skip to content

Instantly share code, notes, and snippets.

@gesellix
Forked from sts/haproxy_maintenance.conf
Last active September 9, 2016 10:35
Show Gist options
  • Save gesellix/c4de9d5e09a66a9e764a to your computer and use it in GitHub Desktop.
Save gesellix/c4de9d5e09a66a9e764a to your computer and use it in GitHub Desktop.
#
# Proof of concept for a HAProxy maintenance mode
#
#
# Relevant docs:
# http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#4-errorfile
# http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#add%20acl
# Control the maintenance page during runtime using the stats socket
#
# To put the whole site in maintenance mode (for all IPs):
# > add acl #0 0.0.0.0/0
#
# To exclude your own ip, so you are able to test things out:
# > add acl #1 8.8.8.8
#
# To exit maintenance mode again simply remove the mask from #0 again:
# > del acl #0 0.0.0.0/0
#
frontend web
bind 0.0.0.0:80
mode http
default_backend web_backend
# use this in case of real errors
errorfile 503 /etc/haproxy/errors/maintenance.http
# maintenance mode - disabled by default
acl web_maintenance src --
acl web_maintenance_ex src --
use_backend web_maintenance if web_maintenance !web_maintenance_ex
backend web
mode http
balance roundrobin
server web01 127.0.0.1:8080 inter 500 rise 3 fall 1 weight 100 slowstart 30s
backend web_maintenence
mode http
errorfile 503 /etc/haproxy/errors/maintenance.http
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment