How to install HAProxy 2.5 Load Balancer on Debian 11

HAProxy is a free, very fast, and reliable reverse proxy offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It is suited for very high-traffic websites and runs the most visited sites.

What is load balancing?

Load balancing ensures the availability, uptime, and performance of your servers, websites, and applications during traffic spikes.

In this tutorial, we are going to learn how to install the latest HAProxy on our Debian 11.

What makes HAProxy so good?

  • Its Perfomance is on another level. HAProxy scales very fast with threads. It can reach 2 million requests over SSL and 100Gpbs for forwarded traffic. This is made possible by event-driven architecture that makes it reacts extremely quickly to any input/output requests.
  • Reliability of HAProxy is exceptional. Alot of effort is made in the direction of making HAProxy more reliable. The development process encourages quality with a long term development cycle. User who use HAProxy have faced minimal problems because the team who develops this are maintained for 5 years in the process of development.
  • It has harden security. HAProxy employs a number of security mechanism such as, use of chroot, priviledge drops, fork prevention, strict protocol, and detailed traces incase of vialotion detection.

New Features of HAProxy

  • It provided better usability around setting variables
  • Has better and descriptive error reporting and logging
  • Has enhanced HTTP and web socket support.
  • The Lua integration now supports an HTTP client for initiating HTTP requests and their is early support for QUIC and HTTP/3
  • HAProxy gives you best in class observability into the traffic that passes throuh it.

Install HAProxy 2.5 on Debian 11

1. Run system update and upgrade

To begin our installation we need to run system update and upgrades in order to make our repositories and packages up to date. Open your terminal and run the following command.

$ sudo apt update && apt upgrade -y

2. Add HAProxy Repository to the system.

To install the latest release of HAProxy on Debian 11, we need to add the following repository to our system. After adding the repo, you may need to check your key if it is self-signed. Self-signed keys are authentic and it doesn’t pose any dangers. Open your terminal and run the following command.

$ curl https://haproxy.debian.net/bernat.debian.org.gpg \
      | gpg --dearmor > /usr/share/keyrings/haproxy.debian.net.gpg

Sample output

Output
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5604  100  5604    0     0  11675      0 --:--:-- --:--:-- --:--:-- 11650

Use the following command to ensure that the key is self-signed

$ echo deb "[signed-by=/usr/share/keyrings/haproxy.debian.net.gpg]" \
      http://haproxy.debian.net bullseye-backports-2.5 main \
      > /etc/apt/sources.list.d/haproxy.list

Next, is to run system updates again to ensure that changes made take effect.

$ sudo apt update
Hit:4 http://deb.debian.org/debian bullseye-backports InRelease                                                 
Hit:5 https://repos-droplet.digitalocean.com/apt/droplet-agent main InRelease                                   
Get:6 http://haproxy.debian.net bullseye-backports-2.5 InRelease [9198 B] 
Get:7 http://haproxy.debian.net bullseye-backports-2.5/main amd64 Packages [1949 B]

From the above, you can see that backports 2.5 had been added successfully.

3. Install HAProxy on Debian

To install HAProxy, on your terminal run the following command;

$ sudo apt install haproxy=2.5.\*

The following output will be displayed.

Output
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Selected version '2.5.0-1~bpo11+1' (HAProxy 2.5:bullseye-backports-2.5 [amd64]) for 'haproxy'
The following additional packages will be installed:
  liblua5.3-0
Suggested packages:
  vim-haproxy haproxy-doc
The following NEW packages will be installed:
  haproxy liblua5.3-0
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 2056 kB of archives.
After this operation, 4609 kB of additional disk space will be used.
Do you want to continue? [Y/n] 

From here press Y and enter to allow installation to continue.

We have successfully installed HAProxy but we can confirm by checking the version of installed HAProxy.

$ haproxy -v 
HAProxy version 2.5.0-1~bpo11+1 2021/11/26 - https://haproxy.org/
Status: stable branch - will stop receiving fixes around Q1 2023.
Known bugs: http://www.haproxy.org/bugs/bugs-2.5.0.html
Running on: Linux 5.10.0-7-amd64 #1 SMP Debian 5.10.40-1 (2021-05-28) x86_64

4. Conclusion

We have successfully installed HAProxy on our Debian 11. You can consult HAProxy documentation for more insights.

You can also check this for Ubuntu installation

About Mason Kipward

I am a technology enthusiast who loves to share gained knowledge through offering daily tips as a way of empowering others. I am fan of Linux and all other things open source.
View all posts by Mason Kipward →

Leave a Reply

Your email address will not be published.