How to Configure HAProxy on CentOS/ RHEL 5/6

HAProxy (High Availability Proxy) is an opensource TCP/HTTP load balancer, we can use this to improve the performace of web sites and services by sending requestess across multiple servers. It is written in C and also fast, efficient and stable. It is created to hanndle high traffic websites.

In this article I will show you the installation of HAProxy on CentOS 6.4 and we will load balance it for HTTP request. I am using 3 instance for this.

Environment Information:

Step 1: On HAProxy Server

Before Installing HAProxy on the server we need to install epel repository on our system depending on our operating system version using following command.

Step 2: Install HAProxy using Yum.

Now we will install haproxy application using following command.

Step 3: Now we will configure HAProxy

We have to modify the configuraion file of haproxy i.e. /etc/haproxy/haproxy.cfg as per our requirement. (Change this configuration as your network requirements)

Step 4: Start HAProxy service

After finishing the edit we will now start the haproxy server by issuing following command. Also we have to add it to auto sratr on system boot.

Finally You have done it.

Now you will able to browse your applicaiton using the IP of the haproxy server. For haproxy Status dashboard you have to browse the URL: It will ask you for the username and password. Use the username and password you defined on the configuraion file as “stats auth”

The following two tabs change content below.

Tapas Mishra

Sr. Engineer (DevOps)
Loves to work on Opensource products. Having experience on Linux environment. Knowledge on Public cloud services like AWS, Rackspace, DigitalOcean, Linode. Please don't hesitate to give a comment on the posts. Your comments are my strength.

Leave a Reply