Web load balancer with HAproxy

This note provides steps for up and running haproxy loadbalancer for http service.

Install haproxy rpm

yum install haproxy

Edit haproxy.cfg
vi /etc/haproxy/haproxy.cfg

maxconn 100000
user haproxy
group haproxy

#log  global
mode http
# option httplog
# option dontlognull
retries 3
option redispatch
maxconn 100000
contimeout      5000
clitimeout      50000
srvtimeout      50000
VIP address. Do not add config at /etc/sysctl.conf
listen webfarm
It can be tcp or http
mode http
# stats enable
# stats auth someuser:somepassword
balance roundrobin
# allow to track source ip
option forwardfor
option httpchk HEAD /linkcheck.html HTTP/1.0
server webA cookie A check
server webB cookie B check
Edit system parameter
vi /etc/sysctl.conf

net.ipv4.ip_nonlocal_bind = 1