{"id":1818,"date":"2020-11-16T17:39:09","date_gmt":"2020-11-16T17:39:09","guid":{"rendered":"https:\/\/linuxways.net\/?p=1818"},"modified":"2020-11-18T16:56:18","modified_gmt":"2020-11-18T16:56:18","slug":"how-to-install-and-configure-haproxy-load-balancer-in-linux","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-and-configure-haproxy-load-balancer-in-linux\/","title":{"rendered":"How to install and configure HAproxy on Ubuntu 20.04 LTS"},"content":{"rendered":"<p>HAproxy is an open-source and lightweight package that offers high availability and load balancing for TCP and HTTP based programs. It distributes the load among the web and application servers. HAproxy is available for nearly all Linux distributions. It is a widely used load balancer that is popular for its efficiency, reliability, and low memory and CPU footprint. In this post, we will explain how to install and configure HAproxy on a Ubuntu system.<\/p>\n<p>We have setup three machines. We will install HAproxy on one server and the Apache web servers on two servers. Our HAproxy server will then act as a load balancer and will distribute the load among Apache web servers.<\/p>\n<p><strong>Note:<\/strong> The procedure and commands mentioned in this post has been tested on <strong>Ubuntu 20.04 LTS (Focal Fossa).<\/strong> The same procedure is also valid for Debian and Mint distributions.<\/p>\n<h2>Network Details<\/h2>\n<p>We will be using three Ubuntu servers; all on the same network. The details of our servers are as follows:<\/p>\n<ol>\n<li>\n<pre>Hostname: HAproxy, IP address: 192.168.72.157 (Frontend server)<\/pre>\n<\/li>\n<li>\n<pre>Hostname: web-server1, IP address: 192.168.72.158 (Backend servers)<\/pre>\n<\/li>\n<li>\n<pre>Hostname: web-server2, IP address: 192.168.72.159 (Backend servers)<\/pre>\n<\/li>\n<\/ol>\n<p><strong>Note:<\/strong> You must have sudo privileges on all the servers.<\/p>\n<p>We will configure one machine as a load balancer and the other two as web servers. The HAproxy server will be our front-end server that will receive the requests from the users and forward them to the two web servers. The web servers will be our Backend servers that will receive those forwarded requests.<\/p>\n<p>This is how our setup looks like:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"791\" height=\"505\" class=\"wp-image-1819\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-486.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-486.png 791w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-486-300x192.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-486-768x490.png 768w\" sizes=\"auto, (max-width: 791px) 100vw, 791px\" \/><\/p>\n<h2>Setting up web servers-Backend servers<\/h2>\n<p>In this section, we will setup two web servers (<strong>web-server1<\/strong> and <strong>web-server2<\/strong>) as our backend servers.<\/p>\n<h3>On web-server1(192.168.72.158)<\/h3>\n<p>Perform the below steps in your web server. Make sure to replace the hostnames and IP addresses with the relevant IP addresses and hostnames of your web servers.<\/p>\n<h4>1. Configure hosts file<\/h4>\n<p>On <strong>web-server1, <\/strong>edit the<strong> \/etc\/hosts<\/strong> file:<\/p>\n<pre>$ sudo nano \/etc\/hosts<\/pre>\n<p>Then add the hostname entry for <strong>HAproxy <\/strong>server as follows:<\/p>\n<pre>hostname-of-HAproxy IP-address-of-HAproxy<br \/><br \/>In our scenario, it would be:<br \/><br \/>HAproxy 192.168.72.157<\/pre>\n<h3>2. Setup Apache webserver<\/h3>\n<p>Now install Apache web server using the below command in Terminal. You can also visit our post on <strong><a href=\"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-apache-web-server-on-linux\/\">How to install the Apache web server on Linux<\/a>.<\/strong><\/p>\n<pre>$ sudo apt install apache2<\/pre>\n<p>Then enable and start the Apache service using the below commands in Terminal:<\/p>\n<pre>$ sudo systemctl enable apache2<\/pre>\n<pre>$ sudo systemctl start apache2<\/pre>\n<p>Create an index file for <strong>web-server1<\/strong> using the below command in Terminal:<\/p>\n<pre>$ echo \"&lt;H1&gt;Hello! This is webserver1: 192.168.72.158 &lt;\/H1&gt;\" | sudo tee \/var\/www\/html\/index.html<\/pre>\n<p>If a firewall is running on your system, you will need to allow Apache traffic through it:<\/p>\n<pre>$ sudo ufw allow 80\/tcp<\/pre>\n<p>Then reload the firewall configurations:<\/p>\n<pre>$ ufw reload<\/pre>\n<p>Now try accessing the site in your web browser by typing <strong>http:\/\/<\/strong> followed by either the IP address or the hostname of your web server.<\/p>\n<pre>http:\/\/ hostname-or-IP-address<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"851\" height=\"248\" class=\"wp-image-1820\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-487.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-487.png 851w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-487-300x87.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-487-768x224.png 768w\" sizes=\"auto, (max-width: 851px) 100vw, 851px\" \/><\/p>\n<p>Alternatively, you can also use the curl command to test the webpage.<\/p>\n<pre>$ curl &lt;hostname-or-IP-address&gt;<\/pre>\n<h3>On web server-2 192.168.72.159)<\/h3>\n<p>Perform the below steps in your second web server. Make sure to replace the hostnames and IP addresses with the relevant IP addresses and hostnames of your web servers.<\/p>\n<h4>1. Configure hosts file<\/h4>\n<p>In <strong>web-server2<\/strong>, edit the <strong>\/etc\/hosts<\/strong> file:<\/p>\n<pre>$ sudo nano \/etc\/hosts<\/pre>\n<p>Then add the hostname entry for <strong>HAproxy <\/strong>server as follows:<\/p>\n<pre>HAproxy 192.168.72.157<\/pre>\n<h4>2. Install Apache webserver<\/h4>\n<p>Now install Apache web server using the below command in Terminal.<\/p>\n<pre>$ sudo apt install apache2<\/pre>\n<p>Then enable and start the Apache service using the below commands in Terminal:<\/p>\n<pre>$ sudo systemctl enable apache2<br \/><br \/>$ sudo systemctl start apache2<\/pre>\n<p>Create an index file for web-server2 using the below command in Terminal:<\/p>\n<pre>$ echo \"&lt;H1&gt;Hello! This is webserver2: 192.168.72.159 &lt;\/H1&gt;\" | sudo tee \/var\/www\/html\/index.html<\/pre>\n<p>Allow Apache in the firewall:<\/p>\n<pre>$ sudo ufw allow 80\/tcp<\/pre>\n<p>and then reload firewall configurations:<\/p>\n<pre>$ ufw reload<\/pre>\n<p>Now try accessing the site in your web browser by typing <strong>http:\/\/<\/strong> followed by either the IP address or the hostname.<\/p>\n<pre>http:\/\/ hostname-or-IP-address<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"944\" height=\"283\" class=\"wp-image-1821\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-488.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-488.png 944w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-488-300x90.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-488-768x230.png 768w\" sizes=\"auto, (max-width: 944px) 100vw, 944px\" \/><\/p>\n<p>Alternatively, you can use the curl command to test the webpage.<\/p>\n<pre>$ curl &lt;hostname-or-IP-address&gt;<\/pre>\n<p>Now our Apache web servers are ready.<\/p>\n<h2>Setting up HAproxy load balancer-Frontend server<\/h2>\n<p>In this section, we will set up an HAproxy load balancer for our <strong>web servers<\/strong>. This HAproxy server will act as a frontend server and accepts incoming requests from clients.<\/p>\n<p>On the <strong>HAproxy <\/strong>server (<strong>192.168.72.157<\/strong>), perform the below steps to setup load balancer.<\/p>\n<h3>1. Configure hosts file<\/h3>\n<p>Edit the <strong>\/etc\/hosts<\/strong> file using the below command in Terminal:<\/p>\n<pre>$ sudo nano \/etc\/hosts<\/pre>\n<p>Add the following hostname entries for both<strong> Apache<\/strong> web servers along with its own hostname<strong>:<\/strong><\/p>\n<pre>192.168.72.157 HAproxy<br \/><br \/>192.168.72.158 web-server1<br \/><br \/>192.168.72.159 web-server2<\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"698\" height=\"188\" class=\"wp-image-1822\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-489.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-489.png 698w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-489-300x81.png 300w\" sizes=\"auto, (max-width: 698px) 100vw, 698px\" \/><\/strong><\/p>\n<p>Now save and close the <strong>\/etc\/hosts<\/strong> file.<\/p>\n<h3>Installing HAproxy load balancer<\/h3>\n<p>Now in this step, we will be installing the HAproxy on one of our Ubuntu server (192.168.72.157). To do so, update apt using the following command in Terminal:<\/p>\n<pre>$ sudo apt-get update<\/pre>\n<p>Then update packages using the below command:<\/p>\n<pre>$ sudo apt-get upgrade<\/pre>\n<p>Now install HAproxy using the following command in Terminal:<\/p>\n<pre>$ sudo sudo apt install haproxy<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"899\" height=\"273\" class=\"wp-image-1823\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-490.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-490.png 899w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-490-300x91.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-490-768x233.png 768w\" sizes=\"auto, (max-width: 899px) 100vw, 899px\" \/><\/p>\n<p>Once the installation of the HAproxy server is finished, you can confirm it using the below command in Terminal:<\/p>\n<pre>$ haproxy -v<\/pre>\n<p>It will show you the installed version of HAproxy on your system which verifies that the HAproxy has been successfully installed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"770\" height=\"73\" class=\"wp-image-1824\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-491.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-491.png 770w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-491-300x28.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-491-768x73.png 768w\" sizes=\"auto, (max-width: 770px) 100vw, 770px\" \/><\/p>\n<h3>Configuring HAproxy as a load balancer<\/h3>\n<p>In the following section, we will configure HAproxy as a load balancer. To do so,<strong> edit the \/etc\/haproxy\/haproxy.cfg<\/strong> file:<\/p>\n<pre>$ sudo nano <strong>\/etc\/haproxy\/haproxy.cfg<\/strong><\/pre>\n<p><strong>Append the following lines in the haproxy.cfg file replacing the IP addresses with your own IP addresses.<\/strong><\/p>\n<p><span style=\"font-size: inherit;\">The <\/span><strong style=\"font-size: inherit;\">frontend web-frontend<\/strong><span style=\"font-size: inherit;\"> in the above configuration lines tells HAproxy to listen to incoming requests on port <\/span><strong style=\"font-size: inherit;\">80<\/strong><span style=\"font-size: inherit;\"> of <\/span><strong style=\"font-size: inherit;\">192.168.72.157<\/strong><span style=\"font-size: inherit;\"> and then forward them to backend servers configured under the <\/span><strong style=\"font-size: inherit;\">backend<\/strong> <strong style=\"font-size: inherit;\">web-backend<\/strong><span style=\"font-size: inherit;\">. While configuring, replace the IP addresses with the relevant IP addresses of your web servers.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"798\" height=\"431\" class=\"wp-image-1825\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-492.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-492.png 798w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-492-300x162.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-492-768x415.png 768w\" sizes=\"auto, (max-width: 798px) 100vw, 798px\" \/><\/p>\n<h3>Configuring HAproxy Monitoring<\/h3>\n<p>With HAproxy monitoring, you can view a lot of information including server status, data transferred, uptime, session rate, etc. To configure HAproxy monitoring, append the following lines in the configuration file located at <strong>\/etc\/haproxy\/haproxy.cfg<\/strong>:<\/p>\n<pre>listen stats<br \/><br \/>bind 192.168.72.157:8080\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 <br \/>\u00a0\u00a0\u00a0 mode http <br \/>\u00a0\u00a0\u00a0 option forwardfor <br \/>\u00a0\u00a0\u00a0 option httpclose <br \/>\u00a0\u00a0\u00a0 stats enable <br \/>\u00a0\u00a0\u00a0 stats show-legends <br \/>\u00a0\u00a0\u00a0 stats refresh 5s <br \/>\u00a0\u00a0\u00a0 stats uri \/stats \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 <br \/>\u00a0\u00a0\u00a0 stats realm Haproxy\\ Statistics <br \/> \u00a0\u00a0 stats auth kbuzdar:kbuzdar\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 #Login User and Password for the monitoring <br \/>\u00a0\u00a0\u00a0 stats admin if TRUE <br \/>\u00a0\u00a0\u00a0 default_backend web-backend<\/pre>\n<p>The above configuration enables the HAproxy \u201c<strong>stats<\/strong>\u201d page using the <strong>stats<\/strong> directive and secures it with <strong>http<\/strong> basic authentication using the username and password defined by the <strong>stats auth <\/strong>directive.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"936\" height=\"426\" class=\"wp-image-1826\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-493.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-493.png 936w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-493-300x137.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-493-768x350.png 768w\" sizes=\"auto, (max-width: 936px) 100vw, 936px\" \/><\/p>\n<p>Once you are done with the configurations, save and close the <strong>haproxy.cfg file.<\/strong><\/p>\n<p><strong>Now verify the configuration file using the below command in Terminal:<\/strong><\/p>\n<pre><strong>$ h<\/strong>aproxy -c -f \/etc\/haproxy\/haproxy.cfg<\/pre>\n<p>The following output shows that the configurations are correct.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"681\" height=\"64\" class=\"wp-image-1827\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-494.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-494.png 681w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-494-300x28.png 300w\" sizes=\"auto, (max-width: 681px) 100vw, 681px\" \/><\/p>\n<p>Now to apply the configurations, restart the HAproxy service:<\/p>\n<pre>$ sudo systemctl restart haproxy.service<\/pre>\n<p>It will stop and then start the HAproxy service.<\/p>\n<p>To check the status of the HAproxy service, the command would be:<\/p>\n<pre>$ sudo systemctl status haproxy.service<\/pre>\n<p>The <strong>active (running) <\/strong>status in the following output shows that the HAproxy server is enabled and running fine.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"823\" height=\"200\" class=\"wp-image-1828\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-495.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-495.png 823w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-495-300x73.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-495-768x187.png 768w\" sizes=\"auto, (max-width: 823px) 100vw, 823px\" \/><\/p>\n<p>Here are some other commands for managing the HAproxy server:<\/p>\n<p>In order to start the HAproxy server, the command would be:<\/p>\n<pre>$ sudo systemctl start haproxy.service<\/pre>\n<p>In order to stop the HAproxy server, the command would be:<\/p>\n<pre>$ sudo systemctl stop haproxy.service<\/pre>\n<p>In case you want to temporarily disable the HAproxy server, the command would be:<\/p>\n<pre>$ sudo systemctl disable haproxy.service<\/pre>\n<p>To re-enable the HAproxy server, the command would be:<\/p>\n<pre>$ sudo systemctl enable haproxy.service<\/pre>\n<h3>Test HAproxy<\/h3>\n<p>Before testing the HAproxy setup, make sure you have connectivity to web servers. From your HAproxy server, ping both web servers either by their IP addresses or hostnames.<\/p>\n<pre>$ ping hostname-or-ip-address<\/pre>\n<p>The following output shows that the HAproxy server can reach both web servers.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"883\" height=\"457\" class=\"wp-image-1829\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-496.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-496.png 883w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-496-300x155.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-496-768x397.png 768w\" sizes=\"auto, (max-width: 883px) 100vw, 883px\" \/><\/p>\n<h3>Test HA Proxy using a web browser<\/h3>\n<p>Now in your HAproxy server, open any web browser and type <strong>http:\/\/<\/strong> followed by the HAproxy server IP address which in our case is 192.168.72.157.<\/p>\n<pre>http:\/\/192.168.72.157<\/pre>\n<p>The HAproxy server will alternatively send the request to both web servers in a round-robin method. You can test this by reloading the webpage a few times.<\/p>\n<p>This is the response we received when we visited the <a href=\"http:\/\/192.168.72.157\">http:\/\/192.168.72.157<\/a> for the first time: <img loading=\"lazy\" decoding=\"async\" width=\"1060\" height=\"247\" class=\"wp-image-1830\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-497.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-497.png 1060w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-497-300x70.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-497-1024x239.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-497-768x179.png 768w\" sizes=\"auto, (max-width: 1060px) 100vw, 1060px\" \/><\/p>\n<p>This is the response we received when we reloaded the webpage: <img loading=\"lazy\" decoding=\"async\" width=\"1062\" height=\"272\" class=\"wp-image-1831\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-498.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-498.png 1062w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-498-300x77.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-498-1024x262.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-498-768x197.png 768w\" sizes=\"auto, (max-width: 1062px) 100vw, 1062px\" \/><\/p>\n<p>You can also use the hostname in place of the HAproxy server IP address.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1055\" height=\"247\" class=\"wp-image-1832\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-499.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-499.png 1055w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-499-300x70.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-499-1024x240.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-499-768x180.png 768w\" sizes=\"auto, (max-width: 1055px) 100vw, 1055px\" \/><\/p>\n<h3>Test HA Proxy using curl<\/h3>\n<p>You can also use the curl command in Linux to test the HAproxy setup. Open the Terminal and type <strong>curl<\/strong> followed by the IP address or the hostname of the HAproxy server.<\/p>\n<pre>$ curl 192.168.72.157<br \/><br \/>or<br \/><br \/>$ curl HAproxy<\/pre>\n<p>Run the curl command a few times and you will see the response alternating between both web servers.<\/p>\n<p>Instead of running the commands several times, you can also run the following one-line script to test the HAproxy server:<\/p>\n<pre>$ while true; do curl 192.168.72.157; sleep 1; done<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"781\" height=\"204\" class=\"wp-image-1833\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-500.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-500.png 781w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-500-300x78.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-500-768x201.png 768w\" sizes=\"auto, (max-width: 781px) 100vw, 781px\" \/><\/p>\n<h3>Testing HAproxy Monitoring<\/h3>\n<p>To access the HAproxy monitoring page, type <strong>http:\/\/<\/strong> followed by the IP address\/hostname of HAproxy server and port 8080\/stats:<\/p>\n<pre><a href=\"http:\/\/192.168.72.157:8080\/stats\">http:\/\/192.168.72.157:8080\/stats<\/a><br \/><br \/>or<br \/><br \/><a href=\"http:\/\/HAproxy:8080\/stats\">http:\/\/HAproxy:8080\/stats<\/a><\/pre>\n<p>The following authentication box will appear. Enter <strong>the username<\/strong> and <strong>password<\/strong> you have configured earlier in the configurations and then press <strong>OK<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1208\" height=\"485\" class=\"wp-image-1834\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-501.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-501.png 1208w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-501-300x120.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-501-1024x411.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-501-768x308.png 768w\" sizes=\"auto, (max-width: 1208px) 100vw, 1208px\" \/><\/p>\n<p>This is the statistics report for our HAproxy server.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1438\" height=\"750\" class=\"wp-image-1835\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-502.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-502.png 1438w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-502-300x156.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-502-1024x534.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/11\/word-image-502-768x401.png 768w\" sizes=\"auto, (max-width: 1438px) 100vw, 1438px\" \/><\/p>\n<p>There you have the installation and configuration of HAproxy load balancer on the Linux system. We have just discussed the basic setup and configuration of HAproxy as a load balancer for Apache web servers. We also looked at some commands for managing the HAproxy server. In the end, we tested the load balancing through the browser and the curl command. For more information, visit HAproxy <a href=\"http:\/\/www.haproxy.org\/#docs\">official documentation<\/a><\/p>\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>HAproxy is an open-source and lightweight package that offers high availability and load balancing for TCP and HTTP based programs. It distributes the load among the web and&hellip;<\/p>","protected":false},"author":4,"featured_media":1839,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5,2],"tags":[52,78],"class_list":["post-1818","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-debian","category-mint","category-ubuntu","tag-apache-web-server","tag-haproxy-load-balancer"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/1818","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=1818"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/1818\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/1839"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=1818"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=1818"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=1818"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}