AMZ DIGICOM

Digital Communication

AMZ DIGICOM

Digital Communication

Install Haproxy on Debian 12

PARTAGEZ

Haproxy is a powerful open source software that can balance loads and set up proxys for applications based on TCP and HTTP. It is often used in high availability systems to effectively distribute queries and thus improve the stability and performance of an application. Haproxy is easily installed under Debian 12: Discover here the procedure to follow.

What is Haproxy?

Haproxy (High Availabibility Proxy) is a load swing and an efficient and reliable reverse proxy, used for Distribute network and application traffic. The application supports both layer 4 (the transport layer, for example TCP) and layer 7 (the application layer, for example HTTP) of the OSI model for the distribution of loads. Thanks to its low latency, its great efficiency and its many configuration possibilities, Haproxy is suitable for businesses of all sizes.

Companies and developers use Haproxy for Divide the load over several Backend servers,, Manage server breakdowns And Improve the general applications of applications. It plays a central role in many web infrastructure, especially for highly available and scalable applications. Its main features include the SSL/TLS termination, the state controls of the Backend servers, the flow limitation and the DDOS protection mechanisms.

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 Debian 12 step by step

Step 1: Update the system

Before installing Haproxy, your Linux distribution must be updated. This makes it possible to ensure that all packages are up to date and that the installation takes place without problem.

The following command updates the packet lists and installs all the updates available for Debian 12:

sudo apt update && sudo apt upgrade -y

bash

Step 2: Install Haproxy

Debian 12 includes Haproxy in its official packages of packages, the installation can therefore be easily done with APT, the integrated packet manager.

sudo apt install haproxy -y

bash

This command downloads and installs Haproxy with all the necessary dependencies.

Step 3: Check the Haproxy version

After installation, check that Haproxy has been successfully installed. To do this, run the following command to display the installed version of Haproxy:

The exit should look like this:

Image: screenshot of the current version of Haproxy in the terminal
After executing the command, you will see the currently installed version of Haproxy in your terminal.

In this way, you make sure that Haproxy has been properly installed.

Step 4: Activate Haproxy as a service

For Haproxy automatically to start the system startup and work permanently, the service must be activated and launched.

sudo systemctl enable haproxy
sudo systemctl start haproxy

bash

Finally, to check that the service is working properly, use the following command:

sudo systemctl status haproxy

bash

If Haproxy works properly, an output comprising  » Active (running) Should appear, as below:

Image: screenshot of Haproxy's condition in the terminal
If the « active (running) » is displayed in the terminal, you have confirmation that Haproxy works without problem.

Step 5: Haproxy basic configuration

The Haproxy configuration file is in the access path /etc/haproxy/haproxy.cfg. Before making changes, it is advisable to make a copy of it, which you can use in the event of doubt or error.

sudo cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.bak

bash

You can now edit the file with the editor of your choice (like Vim or Nano):

sudo nano /etc/haproxy/haproxy.cfg

bash

Here is an example of Simple Haproxy configuration ::

global
	log /dev/log local0
	log /dev/log local1 notice
	chroot /var/lib/haproxy
	stats socket /run/haproxy/admin.sock mode 660 level admin
	stats timeout 30s
	user haproxy
	group haproxy
	daemon
defaults
	log global
	option httplog
	option dontlognull
	timeout connect 5000ms
	timeout client 50000ms
	timeout server 50000ms
frontend http_front
	bind *:80
	default_backend web_servers
backend web_servers
	balance roundrobin
	server server1 192.168.1.10:80 check
	server server2 192.168.1.11:80 check

TXT

This configuration distributes HTTP requests to two web servers using the method Round Robin. It is divided into several sections. First, the global section defines the basic Haproxy parameters. For example, it defines the user account under which Haproxy works and the place where the newspapers are stored. Moreover, A chroot repertoire can be defined In order to execute Haproxy in a limited environment and thus improve its safety.

After the global parameters comes the section defaultswhich defines the default values ​​for all subsequent configurations. It is here, for example, that we determine that Haproxy works in HTTP mode and that HTTP journalization is activated. Various waiting times are also defined.

The other sections of the configuration file, such as frontend And backenddetermine the concrete management of traffic. The « Front » section determines the ports on which Haproxy accepts the requests and the way in which they are transmitted. The « Backend » section then defines the servers to which traffic is redirected. Load Balancing algorithms can be used here.

After changing the file, you must save it and restart Haproxy:

sudo systemctl restart haproxy

bash

The installation of Haproxy on Debian 12 is now completed. The configuration can be adapted at any time by modifying the configuration file.

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