HAProxy is a free HTTP/TCP high accessibility load balancer and intermediary worker. It spreads demands among various workers to moderate issues coming about because of single worker disappointment. HA Proxy is utilized by various prominent sites including GitHub, Bitbucket, Stack Overflow, Reddit, Tumblr, Twitter and Tuenti and is utilized in the OpsWorks item from Amazon Web Services.
Step 1: Update the Systen
You need to use the given command to update the ubuntu current repository and upgrade the ubuntu packages.
Step 2: Install HAproxy
You need to install the HAproxy by using the following command.
sudo apt-get install haproxy -y
After installation of the packages you need to verify the haproxy service status, Use the following command to do that.
sudo systemctl status haproxy
You should get the service output like this.
By default you will get the HAproxy service on boot enable and running state while installation the package.
Step 3: Enable Stats
To enable Haproxy stats is optional, You wants to haproxy stats lets do the following configuration in HAproxy main configuration file.
sudo vim /etc/haproxy/haproxy.cfg
and add the given syntac in the end of the configuration.
stats refresh 30s
stats auth username:password
stats uri /stats
Save and exit from vim text editor and verify the HAproxy syntax by using the following command.
sudo haproxy -f /etc/haproxy/haproxy.cfg -c
If your configuration is valid so then we need to restart the HAproxy service by using the given command.
sudo systemctl restart haproxy
Step 4: HAproxy Stats
To get the HAproxy stats in the browser, You need to open the given url with port.
http://localhost:1936/stats or http://IP_Address:1936/stats along with your username with password.
After login in the Haproxy credentials, You should get the HAproxy dashboard like this.
Congrats on effectively designing HAProxy! With an essential burden balancer arrangement, you can extensively expand your web application execution and accessibility. This guide is anyway a prologue to stack offsetting with HAProxy, which is prepared to do substantially more than what could be canvassed in first-time arrangement guidance. We suggest trying different things with various designs with the assistance of the broad documentation accessible for HAProxy, and afterward begin arranging the heap adjusting for your creation climate.