Skip to content

Instantly share code, notes, and snippets.

@sinansh
Last active March 26, 2018 10:27
Show Gist options
  • Save sinansh/d5050b414ae50f64b3c4ec0e86283d6c to your computer and use it in GitHub Desktop.
Save sinansh/d5050b414ae50f64b3c4ec0e86283d6c to your computer and use it in GitHub Desktop.
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
# turn on stats unix socket
stats socket /var/lib/haproxy/stats
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
listen stats 0.0.0.0:9000 #Listen on all IP's on port 9000
mode http
balance
timeout client 5000
timeout connect 4000
timeout server 30000
#This is the virtual URL to access the stats page
stats uri /haproxy_stats
#Authentication realm. This can be set to anything. Escape space characters with a backslash.
stats realm HAProxy\ Statistics
#The user/pass you want to use. Change this password!
stats auth admin:passwordhere
#This allows you to take down and bring up back end servers.
#This will produce an error on older versions of HAProxy.
stats admin if TRUE
frontend main
mode http
bind 0.0.0.0:80
log global
option httplog
# Capture Host header is important to know whether rules matches or not
capture request header host len 64
# mysite configuration
acl webs hdr_sub(host) blog.omu.edu.tr
acl webs hdr_sub(host) survey.omu.edu.tr
use_backend bk_webs if webs
# yoursite configuration
acl moodle hdr_sub(host) moodle.egitim.omu.edu.tr
use_backend bk_moodle if moodle
# default configuration
default_backend bk_default
backend bk_webs
mode http
balance roundrobin
# cookie SERVERID insert indirect nocache # persistence cookie
option forwardfor # add X-Forwarded-For
# option httpchk HEAD / HTTP/1.0rnHost: www.site1.com
# default-server inter 3s rise 2 fall 3 slowstart 0 # servers default parameters
server node1 10.10.1.27 check
backend bk_moodle
mode http
balance roundrobin
# cookie SERVERID insert indirect nocache # persistence cookie
option forwardfor # add X-Forwarded-For
# option httpchk HEAD / HTTP/1.0rnHost: www.site1.com
# default-server inter 3s rise 2 fall 3 slowstart 0 # servers default parameters
server node1 10.10.1.9 check
backend bk_default
mode http
balance roundrobin
# cookie SERVERID insert indirect nocache # persistence cookie
option forwardfor # add X-Forwarded-For
# option httpchk HEAD / HTTP/1.0rnHost: www.site1.com
# default-server inter 3s rise 2 fall 3 slowstart 0 # servers default parameters
server node1 10.10.1.27 check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment