{"id":22659,"date":"2024-06-05T14:00:14","date_gmt":"2024-06-05T11:00:14","guid":{"rendered":"https:\/\/kifarunix.com\/?p=22659"},"modified":"2024-06-06T07:55:02","modified_gmt":"2024-06-06T04:55:02","slug":"install-and-configure-haproxy-on-ubuntu-24-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-configure-haproxy-on-ubuntu-24-04\/","title":{"rendered":"Install and Configure HAProxy on Ubuntu 24.04"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1051\" height=\"590\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/06\/install-haproxy-ubuntu-24.04.png?v=1717585007\" alt=\"install haproxy on ubuntu 24.04\" class=\"wp-image-22668\" style=\"width:820px;height:auto\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/06\/install-haproxy-ubuntu-24.04.png?v=1717585007 1051w, https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/06\/install-haproxy-ubuntu-24.04-768x431.png?v=1717585007 768w\" sizes=\"(max-width: 1051px) 100vw, 1051px\" \/><\/figure>\n\n\n\n<p>This blog post guides you through how to install and configure HAProxy on Ubuntu 24.04 server. <a href=\"http:\/\/www.haproxy.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">HAProxy<\/a> (<strong>H<\/strong>igh <strong>A<\/strong>vailability Proxy), as you might already be aware, is a free,&nbsp;very&nbsp;fast and reliable solution offering&nbsp;high availability,&nbsp;load balancing, and proxying for TCP and HTTP-based applications. It is particularly suited for very high traffic web sites and powers quite a number of the world&#8217;s most visited ones. It features connection persistence through HTTP cookies, load balancing, header addition, modification, deletion both ways. It has request blocking capabilities and provides interface to display server status.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#installing-ha-proxy-on-ubuntu-24-04\">Installing HAProxy on Ubuntu 24.04<\/a><ul><li><a href=\"#install-ha-proxy-on-ubuntu-24-04\">Install HAProxy on Ubuntu 24.04<\/a><ul><li><a href=\"#create-ha-proxy-ppa-repository-for-ubuntu\">Create HAProxy PPA Repository for Ubuntu<\/a><\/li><li><a href=\"#run-system-update\">Run system update<\/a><\/li><li><a href=\"#install-ha-proxy\">Install HAProxy<\/a><\/li><\/ul><\/li><li><a href=\"#configure-ha-proxy-load-balancer-on-ubuntu-24-04\">Configure HAProxy Load Balancer on Ubuntu 24.04<\/a><ul><li><a href=\"#default-ha-proxy-configuration\">Default HAProxy Configuration<\/a><\/li><li><a href=\"#define-ha-proxy-frontend-configuration-settings\">Define HAProxy Frontend Configuration Settings<\/a><\/li><li><a href=\"#define-ha-proxy-backend-configuration-settings\">Define HAProxy Backend Configuration Settings<\/a><\/li><li><a href=\"#define-ha-proxy-statistics-configuration-settings\">Define HAProxy Statistics Configuration Settings<\/a><\/li><li><a href=\"#validate-ha-proxy-configuration-syntax\">Validate HAProxy Configuration Syntax<\/a><\/li><li><a href=\"#running-ha-proxy\">Running HAProxy<\/a><\/li><\/ul><\/li><li><a href=\"#verify-ha-proxy-load-balancing-setup-on-ubuntu-24-04\">Verify HAProxy Load Balancing Setup on Ubuntu 24.04<\/a><\/li><li><a href=\"#further-reading\">Further Reading<\/a><\/li><li><a href=\"#related-tutorials\">Related Tutorials<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-ha-proxy-on-ubuntu-24-04\">Installing HAProxy on Ubuntu 24.04<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-ha-proxy-on-ubuntu-24-04\">Install HAProxy on Ubuntu 24.04<\/h3>\n\n\n\n<p>HAProxy is available on the default Ubuntu 24.04 repos. However, the available package might not be up-to-date.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt-cache madison haproxy<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>haproxy | 2.8.5-1ubuntu3 | http:\/\/de.archive.ubuntu.com\/ubuntu noble\/main amd64 Packages<\/code><\/pre>\n\n\n\n<p>As you can see, the HAProxy package available on the default repos is version 2.8.5 while the current stable release is version 2.9.7. Check on <a href=\"https:\/\/www.haproxy.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">HAProxy page<\/a>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"create-ha-proxy-ppa-repository-for-ubuntu\">Create HAProxy PPA Repository for Ubuntu<\/h4>\n\n\n\n<p>There are however, PPA repos that provides the latest stable release versions of HAProxy maintained by <a rel=\"noreferrer noopener\" href=\"https:\/\/launchpad.net\/~vbernat\" target=\"_blank\">Vincent Bernat<\/a>. These PPA repos can be installed as follows;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt install software-properties-common<\/pre>\n\n\n\n<p>Replace the value of VER with the current HAProxy branch version number.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>VER=2.9<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo add-apt-repository ppa:vbernat\/haproxy-${VER} --yes<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"run-system-update\">Run system update<\/h4>\n\n\n\n<p>Once the PPA repos are added to system, update your system package cache;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt update<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-ha-proxy\">Install HAProxy<\/h4>\n\n\n\n<p>You can now be able to install the latest stable version of HAProxy;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt-cache madison haproxy<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">   haproxy | 2.9.7-1ppa1~noble | https:\/\/ppa.launchpadcontent.net\/vbernat\/haproxy-2.9\/ubuntu noble\/main amd64 Packages<br>   haproxy | 2.8.5-1ubuntu3 | http:\/\/de.archive.ubuntu.com\/ubuntu noble\/main amd64 Packages<\/pre>\n\n\n\n<p>Note the versions provided by individual repos.<\/p>\n\n\n\n<p>You can now install HAProxy;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt install haproxy<\/pre>\n\n\n\n<p>To check the version of installed HAProxy, run the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">haproxy -v<\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>HAProxy version 2.9.7-1ppa1~noble 2024\/04\/26 - https:\/\/haproxy.org\/\nStatus: stable branch - will stop receiving fixes around Q1 2025.\nKnown bugs: http:\/\/www.haproxy.org\/bugs\/bugs-2.9.7.html\nRunning on: Linux 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"configure-ha-proxy-load-balancer-on-ubuntu-24-04\">Configure HAProxy Load Balancer on Ubuntu 24.04<\/h3>\n\n\n\n<p>With HAProxy installed, you can now proceed with configuration.<\/p>\n\n\n\n<p>HAProxy allows you can define multiple proxy services and configure HAProxy to load balance the traffic for the defined proxies. Proxies are made up of frontend system and one or more back-end systems. The front-end system defines the IP address and port on which the proxy listens as well as the back-end systems to use for a particular proxy.<\/p>\n\n\n\n<p>The main configuration file for HAProxy is&nbsp;<strong><code>\/etc\/haproxy\/haproxy.cfg<\/code><\/strong>.<\/p>\n\n\n\n<p>The HAProxy configuration file is made up of four sections;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>global<\/code>: The global section defines process-wide security and performance tunings that affect HAProxy at a low level.<\/li>\n\n\n\n<li><code>defaults<\/code>: The global section defines the configuration settings that are applied to all of the&nbsp;<code>frontend<\/code>&nbsp;and&nbsp;<code>backend<\/code>&nbsp;sections. You can define multiple default sections but the sub-sequent defaults sections override that came before it.<\/li>\n\n\n\n<li><code>frontend<\/code>: When HAProxy is placed as a reverse proxy, the&nbsp;<code>frontend<\/code>&nbsp;section defines the IP addresses and ports that clients can connect to.<\/li>\n\n\n\n<li><code>backend<\/code>: The backend section defines the group of servers that will be load balanced and assigned to handle requests.<\/li>\n<\/ul>\n\n\n\n<p>The&nbsp;<code>frontend<\/code>&nbsp;and&nbsp;<code>backend<\/code>&nbsp;sections can be combined using the<code>&nbsp;listen<\/code>&nbsp;section. It can also be used to server&nbsp;<a href=\"https:\/\/www.haproxy.com\/blog\/exploring-the-haproxy-stats-page\/\" target=\"_blank\" rel=\"noreferrer noopener\">HAProxy statistics page<\/a>.<\/p>\n\n\n\n<p>Read more about these sections on <a href=\"https:\/\/www.haproxy.com\/blog\/the-four-essential-sections-of-an-haproxy-configuration\/\" target=\"_blank\" rel=\"noreferrer noopener\">Essential Sections of an HAProxy Configuration<\/a>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"default-ha-proxy-configuration\">Default HAProxy Configuration<\/h4>\n\n\n\n<p>The default HAProxy file configuration looks like as shown below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> grep -v '^\\s*#' \/etc\/haproxy\/haproxy.cfg<\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>global\n\tlog \/dev\/log\tlocal0\n\tlog \/dev\/log\tlocal1 notice\n\tchroot \/var\/lib\/haproxy\n\tstats socket \/run\/haproxy\/admin.sock mode 660 level admin\n\tstats timeout 30s\n\tuser haproxy\n\tgroup haproxy\n\tdaemon\n\n\tca-base \/etc\/ssl\/certs\n\tcrt-base \/etc\/ssl\/private\n\n        ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384\n        ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256\n        ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets\n\ndefaults\n\tlog\tglobal\n\tmode\thttp\n\toption\thttplog\n\toption\tdontlognull\n        timeout connect 5000\n        timeout client  50000\n        timeout server  50000\n\terrorfile 400 \/etc\/haproxy\/errors\/400.http\n\terrorfile 403 \/etc\/haproxy\/errors\/403.http\n\terrorfile 408 \/etc\/haproxy\/errors\/408.http\n\terrorfile 500 \/etc\/haproxy\/errors\/500.http\n\terrorfile 502 \/etc\/haproxy\/errors\/502.http\n\terrorfile 503 \/etc\/haproxy\/errors\/503.http\n\terrorfile 504 \/etc\/haproxy\/errors\/504.http\n<\/code><\/pre>\n\n\n\n<p>In our configuration file, we will modify the above to include the <code><strong>frontend<\/strong><\/code> and <code><strong>backend<\/strong><\/code> sections.<\/p>\n\n\n\n<p>Before you can proceed, make a backup of the default config file;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo cp \/etc\/haproxy\/haproxy.cfg{,.factory}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"define-ha-proxy-frontend-configuration-settings\">Define HAProxy Frontend Configuration Settings<\/h4>\n\n\n\n<p>As stated above, the&nbsp;<code>frontend<\/code>&nbsp;section defines the IP addresses and ports that clients can connect to (The IP address and ports on the HAProxy server itself). Therefore, this is how our frontend configuration is like;<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>frontend\n        bind 192.168.122.64:443 ssl crt \/etc\/ssl\/certs\/haproxy.pem\n        default_backend webapps\n        option forwardfor\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>bind<\/code><\/strong>: Define one or more listening addresses and\/or ports in a frontend server.<\/li>\n\n\n\n<li><code><strong>ssl<\/strong>&nbsp;<strong>crt<\/strong><\/code>: Configures HAProxy SSL Termination and specifies the path to SSL\/TLS certificate.<\/li>\n\n\n\n<li><code><strong>default_backend<\/strong><\/code>:&nbsp;Specifies the backend to use when no &#8220;use_backend&#8221; rule has been matched.<\/li>\n\n\n\n<li><code><strong>option forwardfor<\/strong><\/code>: HAProxy operates in reverse-proxy mode. This option enable the backend servers to see the IP addresses of the clients instead of the IP address for HAProxy server.<\/li>\n<\/ul>\n\n\n\n<p>NOTE: <\/p>\n\n\n\n<p>In this demo, our proxied backends uses SSL\/TLS certificates. As such, instead of configuring each backend application to terminate its SSL\/TLS connection (<strong>SSL Pass through<\/strong>), we will configure HAProxy as an SSL\/TLS certificate termination point (<strong>SSL Termination<\/strong>).<\/p>\n\n\n\n<p>If you are not using SSL\/TLS termination, remove the SSL part of the bind line, <code><strong>ssl crt \/etc\/ssl\/certs\/haproxy.pem<\/strong><\/code>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"define-ha-proxy-backend-configuration-settings\">Define HAProxy Backend Configuration Settings<\/h4>\n\n\n\n<p>In this section, we will, in the basic form, a create basic configuration to distribute traffic across two backend web servers. it defines the HAProxy Scheduling Algorithms and the backend servers whose requests are being proxied\/load balanced.<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>backend webapps\n        balance roundrobin\n        server  app01   192.168.122.62:80 check\n        server  app02   192.168.122.63:80 check\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>balance<\/strong>&nbsp;parameter defines the load balancer scheduling algorithm.\n<ul class=\"wp-block-list\">\n<li><strong>roundrobin<\/strong>&nbsp;selects the servers in turns.<\/li>\n\n\n\n<li>Other common algorithms is&nbsp;<strong>leastconn<\/strong>&nbsp;which enabled the load balancer to forward request to servers with least connections.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>server<\/strong>&nbsp;setting specify the servers available in the back end.\n<ul class=\"wp-block-list\">\n<li><strong>check&nbsp;<\/strong>option enables health checks on the server such that if one of them is down, requests are directed to the available backend servers.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"define-ha-proxy-statistics-configuration-settings\">Define HAProxy Statistics Configuration Settings<\/h4>\n\n\n\n<p>According to <a rel=\"noreferrer noopener\" href=\"https:\/\/www.haproxy.com\/blog\/exploring-the-haproxy-stats-page\/#:~:text=HAProxy%20also%20ships%20with%20a,%2C%20backend%2C%20and%20server%20basis.\" target=\"_blank\">HAProxy Stats page<\/a>, HAProxy ships with a dashboard called the <strong>HAProxy Stats page<\/strong> that shows an abundance of metrics covering the health of the servers, current request rates, response times, and more. These metrics gives granular data on a per-frontend, backend, and server basis. This can be enabled using the <code>stats enable<\/code>&nbsp;directive,&nbsp;which can be added to either frontend or listen section. We used a listen section in this tutorial.<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>listen stats\n        bind 192.168.122.64:8443 ssl crt \/etc\/ssl\/certs\/haproxy.pem\n        stats enable                    # enable statistics reports  \n        stats hide-version              # Hide the version of HAProxy\n        stats refresh 30s               # HAProxy refresh time\n        stats show-node                 # Shows the hostname of the node\n        stats auth haadmin:P@ssword     # Enforce Basic authentication for Stats page\n        stats uri \/stats                # Statistics URL\n<\/code><\/pre>\n\n\n\n<p>Note that the line, <code>bind 192.168.122.64:8443 ssl crt \/etc\/ssl\/certs\/haproxy.pem<\/code>, defines the frontend IP and port to access the HAProxy stats as well as the SSL\/TLS cert to use.<\/p>\n\n\n\n<p>Save and exit the file once done with configuration.<\/p>\n\n\n\n<p>In general, this is how our configuration is like. <strong>NOTE<\/strong> that we added the line, <strong>tune.ssl.default-dh-param 2048<\/strong>, to SSL\/TLS configuration options section.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vim \/etc\/haproxy\/haproxy.cfg<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>global\n\tlog \/dev\/log\tlocal0\n\tlog \/dev\/log\tlocal1 notice\n\tchroot \/var\/lib\/haproxy\n\tstats socket \/run\/haproxy\/admin.sock mode 660 level admin\n\tstats timeout 30s\n\tuser haproxy\n\tgroup haproxy\n\tdaemon\n\n\tca-base \/etc\/ssl\/certs\n\tcrt-base \/etc\/ssl\/private\n\n        ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384\n        ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256\n        ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets\n       tune.ssl.default-dh-param 2048\n\ndefaults\n\tlog\tglobal\n\tmode\thttp\n\toption\thttplog\n\toption\tdontlognull\n        timeout connect 5000\n        timeout client  50000\n        timeout server  50000\n\terrorfile 400 \/etc\/haproxy\/errors\/400.http\n\terrorfile 403 \/etc\/haproxy\/errors\/403.http\n\terrorfile 408 \/etc\/haproxy\/errors\/408.http\n\terrorfile 500 \/etc\/haproxy\/errors\/500.http\n\terrorfile 502 \/etc\/haproxy\/errors\/502.http\n\terrorfile 503 \/etc\/haproxy\/errors\/503.http\n\terrorfile 504 \/etc\/haproxy\/errors\/504.http\nfrontend kifarunixlb\n        bind 192.168.122.64:443 ssl crt \/etc\/ssl\/certs\/haproxy.pem\n        default_backend webapps\n        option forwardfor\nbackend webapps\n        balance roundrobin\n        server  app01   192.168.122.62:80 check\n        server  app02   192.168.122.63:80 check\nlisten stats\n        bind 192.168.122.64:8443 ssl crt \/etc\/ssl\/certs\/haproxy.pem\n        stats enable                    # enable statistics reports  \n        stats hide-version              # Hide the version of HAProxy\n        stats refresh 30s               # HAProxy refresh time\n        stats show-node                 # Shows the hostname of the node\n        stats auth haadmin:P@ssword     # Enforce Basic authentication for Stats page\n        stats uri \/stats                # Statistics URL\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"validate-ha-proxy-configuration-syntax\">Validate HAProxy Configuration Syntax<\/h4>\n\n\n\n<p>Once done with configuration, run the command below to verify the HAProxy config syntax validation before you can start it;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo haproxy -f \/etc\/haproxy\/haproxy.cfg -c -V<\/pre>\n\n\n\n<p>If all is well, you should get the output;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Configuration file is valid<\/pre>\n\n\n\n<p>Otherwise, you will get errors on stdout. Be sure to fix before you can proceed.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"running-ha-proxy\">Running HAProxy<\/h4>\n\n\n\n<p>When installed, HAProxy is started and enabled to run on system boot by default. You can restart it by running the command below<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl restart haproxy<\/pre>\n\n\n\n<p>To check the status;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl status haproxy<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\u25cf haproxy.service - HAProxy Load Balancer\n     Loaded: loaded (\/lib\/systemd\/system\/haproxy.service; enabled; vendor preset: enabled)\n     Active: active (running) since Fri 2024-06-03 20:45:33 UTC; 7s ago\n       Docs: man:haproxy(1)\n             file:\/usr\/share\/doc\/haproxy\/configuration.txt.gz\n    Process: 21423 ExecStartPre=\/usr\/sbin\/haproxy -f $CONFIG -c -q $EXTRAOPTS (code=exited, status=0\/SUCCESS)\n   Main PID: 21425 (haproxy)\n      Tasks: 3 (limit: 2282)\n     Memory: 39.5M\n     CGroup: \/system.slice\/haproxy.service\n             \u251c\u250021425 \/usr\/sbin\/haproxy -Ws -f \/etc\/haproxy\/haproxy.cfg -p \/run\/haproxy.pid -S \/run\/haproxy-master.sock\n             \u2514\u250021440 \/usr\/sbin\/haproxy -Ws -f \/etc\/haproxy\/haproxy.cfg -p \/run\/haproxy.pid -S \/run\/haproxy-master.sock\n\nJun 03 20:45:33 haproxy.kifarunix.com systemd[1]: Starting HAProxy Load Balancer...\nJun 03 20:45:33 haproxy.kifarunix.com haproxy[21425]: Proxy kifarunixlb started.\nJun 03 20:45:33 haproxy.kifarunix.com haproxy[21425]: Proxy kifarunixlb started.\nJun 03 20:45:33 haproxy.kifarunix.com haproxy[21425]: Proxy webapps started.\nJun 03 20:45:33 haproxy.kifarunix.com haproxy[21425]: Proxy webapps started.\nJun 03 20:45:33 haproxy.kifarunix.com haproxy[21425]: Proxy stats started.\nJun 03 20:45:33 haproxy.kifarunix.com haproxy[21425]: Proxy stats started.\nJun 03 20:45:33 haproxy.kifarunix.com haproxy[21425]: [NOTICE] 156\/204533 (21425) : New worker #1 (21440) forked\nJun 03 20:45:33 haproxy.kifarunix.com systemd[1]: Started HAProxy Load Balancer.\n<\/code><\/pre>\n\n\n\n<p>If UFW is running, Open port 443 as well as the statistics port;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo ufw allow 443\/tcp<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo ufw allow 8443\/tcp<\/pre>\n\n\n\n<p>You can use iptables if you like. Or even firewalld.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"verify-ha-proxy-load-balancing-setup-on-ubuntu-24-04\">Verify HAProxy Load Balancing Setup on Ubuntu 24.04<\/h3>\n\n\n\n<p>You can now access your HAProxy from browser to confirm your LB setup. Use the address, <code><strong>https[s]:\/\/lb-server-IP-or-hostname<\/strong><\/code>.<\/p>\n\n\n\n<p>The first page shows content from the first defined backend, in this demo, app01. Remember the LB algorithm used here, <code><strong>roundrobin<\/strong><\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1196\" height=\"360\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/06\/haproxy-lb-app001.png?v=1717583422\" alt=\"setup haproxy on ubuntu 24.04\" class=\"wp-image-22663\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/06\/haproxy-lb-app001.png?v=1717583422 1196w, https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/06\/haproxy-lb-app001-768x231.png?v=1717583422 768w\" sizes=\"(max-width: 1196px) 100vw, 1196px\" \/><\/figure>\n\n\n\n<p>If you reload the url, the content from the second app shows;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1204\" height=\"350\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/06\/haproxy-lb-app002.png?v=1717583438\" alt=\"\" class=\"wp-image-22664\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/06\/haproxy-lb-app002.png?v=1717583438 1204w, https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/06\/haproxy-lb-app002-768x223.png?v=1717583438 768w\" sizes=\"(max-width: 1204px) 100vw, 1204px\" \/><\/figure>\n\n\n\n<p>You can also check the statistics of your HAProxy, <code><strong>http[s]:\/\/lb-server-IP-or-hostname[:port]\/stats<\/strong><\/code>. If you enabled basic authentication, you are prompted to authenticate.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1187\" height=\"402\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/06\/haproxy-stats-authentication.png?v=1717583816\" alt=\"haproxy basic authentication\" class=\"wp-image-22665\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/06\/haproxy-stats-authentication.png?v=1717583816 1187w, https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/06\/haproxy-stats-authentication-768x260.png?v=1717583816 768w\" sizes=\"(max-width: 1187px) 100vw, 1187px\" \/><\/figure>\n\n\n\n<p>And there you got your statistics.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1622\" height=\"547\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/06\/haproxy-statistics.png?v=1717583835\" alt=\"haproxy statistics\" class=\"wp-image-22666\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/06\/haproxy-statistics.png?v=1717583835 1622w, https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/06\/haproxy-statistics-768x259.png?v=1717583835 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/06\/haproxy-statistics-1536x518.png?v=1717583835 1536w\" sizes=\"(max-width: 1622px) 100vw, 1622px\" \/><\/figure>\n\n\n\n<p>That brings us to the end of our tutorial on how to installing HAProxy on Ubuntu 24.04.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"further-reading\">Further Reading<\/h3>\n\n\n\n<p><a href=\"https:\/\/cbonte.github.io\/haproxy-dconv\/2.0\/configuration.html\" target=\"_blank\" rel=\"noreferrer noopener\">HAProxy Configuration Manual<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"related-tutorials\">Related Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-and-setup-haproxy-on-centos-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install and Setup HAProxy on CentOS 8<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/setup-haproxy-load-balancer-on-fedora-30-fedora-29\/\" target=\"_blank\" rel=\"noreferrer noopener\">Setup HAProxy Load Balancer on Fedora 30\/Fedora 29<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/kifarunix.com\/how-to-install-and-configure-pound-apache-load-balancer-on-ubuntu-16-04\/\" target=\"_blank\">How to Install and Configure Pound as Apache HTTP Load balancer on Ubuntu 16.04<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This blog post guides you through how to install and configure HAProxy on Ubuntu 24.04 server. HAProxy (High Availability Proxy), as you might already be<\/p>\n","protected":false},"author":10,"featured_media":22668,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,1032,92],"tags":[1033,7511,95,7396],"class_list":["post-22659","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-haproxy","category-load-balancers","tag-haproxy","tag-install-haproxy-ubuntu","tag-load-balancer","tag-ubuntu-24-04","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/22659"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=22659"}],"version-history":[{"count":6,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/22659\/revisions"}],"predecessor-version":[{"id":22689,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/22659\/revisions\/22689"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/22668"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=22659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=22659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=22659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}