HAProxy(High Availability Proxy) is an open source load balancer which can load balance any TCP service. It is particularly suited for HTTP load balancing as it supports session persistence and layer 7 processing.

>> Haproxy does loadbalancing between the http apache webserver.That is when a client sent a request to the webserver , the request goes to the loadbalacer
and then the loadbalancer ie Haproxy distribute the request among the webserver present in the loadbalancer.

Load Balancing between two apache web servers using the HAproxy.

Our webserver is
1> web01  (
2> web02  (

Loabalancer (

And a loadbalancing server is load01

Let install haproxy on loadbalancer machine


1.First I have install haproxy on server load01 ( )

loadb01$ sudo apt-get install haproxy

2.Now take the backup of the haproxy original file

loadb01$ sudo mv /etc/haproxy/haproxy.cfg /etc/haproxy/backup_haproxy.cfg
loadb01$ sudo vi /etc/haproxy/haproxy.cfg

maxconn 4096
user haproxy
group haproxy

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 web01 cookie LSW_WEB01 check
server web02 cookie LSW_WEB02 check

3.We needto enable the haproxy for that we need to enable it in /etc/default/haproxy

# Set ENABLED to 1 if you want the init script to start haproxy.
# Add extra flags here.
#EXTRAOPTS=”-de -m 16″

4.Now let start haproxy

/etc/init.d/haproxy start




Good contents== http://support.severalnines.com/entries/23612682-Install-HAProxy-and-Keepalived-Virtual-IP-


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s