haproxy.cfg
# This is a test configuration.
# It requires another server running on local port 9000, preferably httpterm
# with the file 'httpterm-basic.cfg' from the same directory.
#
# It will wait for HTTP connections on port 8000 and TCP connections on port
# 8001. It will load-balance them across active servers, and will be able to
# validate queuing. Stats are available at URI /?stats.
global
maxconn 4096
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
listen webcluster *:80
mode http
stats enable
stats auth us3r:passw0rd
balance roundrobin
option httpchk HEAD / HTTP/1.0
option forwardfor
cookie LSW_WEB insert
option httpclose
server srv1 192.168.0.183:7003 cookie s1 check
server srv2 192.168.0.183:7006 cookie s2 check
server srv3 192.168.0.197:7004 cookie s2 check
keepalived.conf
notification_email {
your@emailaddress.com # Email address for notifications
}
notification_email_from loadb01@domain.ext # The from address for the notifications
smtp_server 127.0.0.1 # You can specifiy your own smtp server here
smtp_connect_timeout 15
}
# Define the script used to check if haproxy is still working
vrrp_script chk_haproxy {
script "killall -0 haproxy"
interval 2
weight 2
}
# Configuation for the virtual interface
vrrp_instance VI_1 {
interface eth0
state BACKUP # set this to BACKUP on the other machine
priority 100 # set this to 100 on the other machine
virtual_router_id 51
smtp_alert # Activate email notifications
authentication {
auth_type AH
auth_pass myPassw0rd # Set this to some secret phrase
}
# The virtual ip address shared between the two loadbalancers
virtual_ipaddress {
192.168.0.200
}
# Use the script above to check if we should fail over
track_script {
chk_haproxy
}
}