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


global
maxconn 100000
user haproxy
group haproxy

defaults
#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 192.168.1.3:80
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 192.168.1.1:80 cookie A check
server webB 192.168.1.2:80 cookie B check
Edit system parameter
vi /etc/sysctl.conf

net.ipv4.ip_nonlocal_bind = 1

Comments