AMZ DIGICOM

Digital Communication

AMZ DIGICOM

Digital Communication

Install Haproxy on Ubuntu 22.04

PARTAGEZ

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.

Image: screenshot of the current version of Haproxy in the terminal
After executing the command, the current installed version of Haproxy will be displayed.

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:

Image: screenshot of the current Haproxy status in the terminal
In the exit of the terminal, the “active (running)” status indicates that Haproxy works without problem.

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.

Télécharger notre livre blanc

Comment construire une stratégie de marketing digital ?

Le guide indispensable pour promouvoir votre marque en ligne

En savoir plus

Web Marketing

Localhost: how to connect to 127.0.0.1?

When you call an IP address, you are usually trying to contact another computer on the Internet. However, if you call the IP address 127.0.0.1,

Web Marketing

What is Proxmox? – IONOS

Proxmox is an open source platform dedicated to virtualization and containerization. It allows you to manage and operate virtual machines, containers and high availability clusters.

Souhaitez vous Booster votre Business?

écrivez-nous et restez en contact