Skip to content

Instantly share code, notes, and snippets.

@snambi
Created March 30, 2017 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snambi/6ed72d050659bde47d74a5d46604d8dd to your computer and use it in GitHub Desktop.
Save snambi/6ed72d050659bde47d74a5d46604d8dd to your computer and use it in GitHub Desktop.
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
option dontlognull
contimeout 5000
clitimeout 50000
srvtimeout 50000
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
frontend http-in
bind 0.0.0.0:80
acl xyz hdr(host) -i xyz.blah.com
acl abc hdr(host) -i abc.blah.com
acl default hdr_end(host) -i .blah.com
## figure out which one to use
use_backend xyz_cluster if xyz
use_backend abc_cluster if abc
use_backend direct_forward if default
backend xyz_cluster
option forwardfor
server node1 10.1.1.12:8080
# sends "abc.blah.com"
backend abc_cluster
option forwardfor
server node1 10.1.1.11:8080
# forward to actual destination
backend direct_forward
option httpclose
option http_proxy
listen stats :9000
mode http
stats enable
stats hide-version
stats realm Haproxy\ Statistics
stats uri /stats
stats auth test:test123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment