Home General Topics Configuration of HAProxy Load Balancer on CentOS

Configuration of HAProxy Load Balancer on CentOS

by Bella

HAProxy stands for High Availability Proxy.  It is a very fast and reliable solution for high availability and load balancing. HAProxy is used as TCP/HTTP Load Balancer and for proxy Solutions. The HAProxy application will share the workload with multiple servers.

Steps for Installation and Configuring  HAProxy

Step 1: Before proceeding with the installation of  HAProxy in the server, we need to install the epel repository on our system depending on the operating system version using the following command.

CentOS/RHEL 6 , 32 bit:
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

CentOS/RHEL 6 , 64 bit:
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Step 2. Install HAProxy using Yum

yum install haproxy

Step 3: Configure HAProxy

The configuration file of haproxy is  /etc/haproxy/haproxy.cfg and modify the configuration file as per our requirement.

vi /etc/haproxy/haproxy.cfg global

log local0
log local1 debug
maxconn 45000 # Total Max Connections. This is dependent on ulimit
user haproxy
group haproxy

timeout server 86400000
timeout connect 86400000
timeout client 86400000
timeout queue 1000s

# Configuration for HTTP site
listen http_idroot
mode http
balance roundrobin # Load Balancing algorithm
option httpchk
option forwardfor
server server1 weight 1 maxconn 512 check
server server2 weight 1 maxconn 512 check

# Configuration for HTTPS site listen
mode tcp
balance source# Load Balancing algorithm
reqadd X-Forwarded-Proto:\ http
server server1 weight 1 maxconn 512 check
server server2 weight 1 maxconn 512 check

listen stats
mode http
option httpclose
balance roundrobin
stats uri /
stats realm Haproxy\ Statistics
stats refresh 5s
stats auth admin:passwd123

Step4: Start the haproxy service using the following command

# service haproxy start
# chkconfig haproxy on

If you require help, contact SupportPRO Server Admin

Server not running properly? Get A FREE Server Checkup By Expert Server Admins - $125 Value

Leave a Comment


Sales and Support

Phone: 1-(847) 607-6123
Fax: 1-(847)-620-0626
Sales: sales@supportpro.com
Support: clients@supportpro.com
Skype ID: sales_supportpro

Postal Address

1020 Milwaukee Ave, #245,
Deerfield, IL-60015

©2022  SupportPRO.com. All Rights Reserved