Haproxy is popular software that can be used as a donation proxy and as load swing. It can be installed under Ubuntu 22.04 easily and in just a few steps.
What is Haproxy?
Haproxy (High Availabibility Proxy) is powerful open source software, which can act either as load swingor like Reverse proxy. It is commonly used for Divide traffic on several serversthus improving the availability and performance of web applications. Haproxy is a proven solution, especially in evolving and resilient architectures.
Thanks to its high efficiency, Haproxy can treat thousands of requests per second without overloading system resources. The software supports Different Load Balancing methods such as the Round Robin,, Least Connections and the hash skill IP Source. It also offers features such as SSL termination, health checks and Sticky Sessions To optimize traffic management. Another force lies in the ability to redirect traffic according to specific rules or header information.
Haproxy is used in many large companies and cloud environments. The configuration is made via a simple but flexible configuration file, allowing detailed adaptation to your needs.
Dedicated servers
Performance and innovation
Take advantage of your own server, with dedicated hardware, cloud integration, minute invoicing and Intel® Xeon® or AMD processor.
Haproxy installation on Ubuntu 22.04 step by step
Step 1: Update the system
Before starting the installation, make sure that your Linux distribution is up to date. This guarantees that all packages are updated and that the potential security flaws have been corrected. To do this, open a terminal and run the following commands:
sudo apt update && sudo apt upgrade -y
bash
This command sequence first updates the list of packages to determine the latest versions of installed software. Then all packages are updated to their last versions. The parameter -y guarantees the validation of all updates.
Step 2: Install Haproxy
Once the system is up to date, you can install Haproxy with the following command:
sudo apt install haproxy -y
bash
This command downloads Haproxy from the Ubuntu official packages and installs the application. Installation is generally done quickly because Haproxy is a light program. You can then check if Haproxy has been successfully installed by executing the following command:
The output must display the installed version of Haproxy.


Step 3: Activate and start the Haproxy service
After installation, check that the Haproxy service is running. To start, start Haproxy as a administrator with the following command:
sudo systemctl start haproxy
bash
To check the start of the service, use this command:
sudo systemctl status haproxy
bash
If Haproxy works, the output should look like this:


For Haproxy automatically after restarting, activate the service with:
sudo systemctl enable haproxy
bash
Step 4: Configure Haproxy
Haproxy configuration is done via the configuration file /etc/haproxy/haproxy.cfg. Before making changes, it is recommended to create a backup of the original file:
sudo cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.backup
bash
Note
By responding to the original file, you make sure you can return to a functional state at any time. In this way, changes can be made without risk.
To edit the original file, open it with the text editor of your choice, such as Nano or Vim. In our example, we use Nano:
sudo nano /etc/haproxy/haproxy.cfg
bash
Here is a simple example Load Balancing configuration:
frontend http_front
bind *:80
default_backend web_servers
backend web_servers
balance roundrobin
server web1 192.168.1.10:80 check
server web2 192.168.1.11:80 check
In the example of LOAD BALANCER, HTTP traffic entering the 80 port is divided between two Backend, « Web1 » and « Web2 » servers. The distribution of the load is carried out according to the Round Robin method, which makes it possible to distribute the alternating requests between the servers.
Step 5: Restart and test Haproxy
After changing the configuration, Haproxy must be restarted so that the changes take effect. This is done with the next order in the terminal:
sudo systemctl restart haproxy
bash
In case of errors, you can check the Haproxy configuration file to detect syntax errors with the command below:
haproxy -c -f /etc/haproxy/haproxy.cfg
bash
A correct configuration is confirmed by the display of « File is valid configuration ». You can now test if Haproxy works as planned by entering the public IP address or the domain name of your server in a browser.
GPU servers
Hardware dedicated with a powerful graphics card
Use the GPU calculation power in all flexibility to manage large amounts of data and only pay the resources used.

