HAProxyLoad Balancer

How to Install and Configure HAProxy on CentOS or Amazon Linux

In this tutorial, we explain How to Install and Configure HAProxy on CentOS or Amazon Linux. HAProxy is very popular open source software as it is free and it provides HA (high availability) load balancer and it provides a proxy server for TCP and HTTP-based applications that send/forward requests to multiple servers (backend machine).How to Install and Configure HAProxy on CentOS or Amazon Linux

HAProxy is used by many websites such as GitHub, GoDaddy, Bitbucket, Stack Overflow and etc because it is very fast and reliable solution for (HA) high availability, it supports TCP and HTTP-based applications and load balancing. the main feature of using HAPRoxy is to get 99.999% uptime for websites and it is not possible with a single server/machine.

In this article, you will learn the simple steps to install and configure HAProxy on Centos Linux.

Step to install HAProxy on Centos or Amazon Linux

By Default HAProxy package is available in the yum repository for CentOS or Amazon Linux systems.

Steps to Configure HAProxy.cfg

Locate your HAProxy configuration file  – /etc/haproxy/haproxy.cfg

HAProxy.cfg sample file

Change the IP and hostname with your server details. Whenever there is any request on IP 192.168.5.25 on port 80, HAProxy will be redirected to port 80 on backend server “192.168.5.200” and “192.168.5.201”. Similarly, when there is a request on HAProxy on port 443 it will be sent to the port of “192.168.5.200” and “192.168.5.201” servers.

Step to start HAPRoxy Service on Centos or Amazon Linux machine

Add HAProxy service to auto start on boot

HAProxy Command Reference/Tips:

Command to verify HAProxy.cfg file:

Whenever you do any changes to the HAPRoxy.cfg file on CentOS or Amazon Linux check HAProxy file is valid/error/warring. Once you check HAProxy file is valid then reload the file.

Command to use the updated HAProxy file without restarting HAProxy service.

Command to Verify HAProxy service running or not

Command to restart HAProxy service

HAProxy SysAdmin Tips:

  • Before editing HAProxy file take backup and then proceed with changes.
  • Whenever you do any changes to HAProxy.cfg file, Check is there any errors/warring command is mention above.
  • Avoid restarting HAProxy service on minor changes in the HAProxy config file.

In this article, you learn how to install and configure HAProxy on CentOS or Amazon Linux

Related Articles

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close

Adblock Detected

Please consider supporting us by disabling your ad blocker