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 Ubuntu 20.04.
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.
Installing HAProxy on Ubuntu 20.04
1. Run system updates
In oreder to make our repositories current, we need to update our system with the following update command.
$ sudo apt update && apt upgrade -y
When updates are complete, next is to add Vbernat PPA.
2. Enable Vbernet PPA for HAProxy
The reason we are using the PPA here is to ensure that we install the latest version of HAProxy with the newest cool features. Add the following command to install software common properties.
$ sudo apt-get install --no-install-recommends software-properties-common
This command helps you to manage any PPAs you installed in your system.
Next is to add Vbernet PPA to our system with the following command.
$ sudo add-apt-repository ppa:vbernat/haproxy-2.5
Output HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It is particularly suited for web sites crawling under very high loads while needing persistence or Layer7 processing. Supporting tens of thousands of connections is clearly realistic with todays hardware. Its mode of operation makes its integration into existing architectures very easy and riskless, while still offering the possibility not to expose fragile web servers to the Net. This PPA contains packages for HAProxy 2.5. More info: https://launchpad.net/~vbernat/+archive/ubuntu/haproxy-2.5 Press [ENTER] to continue or Ctrl-c to cancel adding it.
Press enter to allow the installation to continue.
You need to run system-wide updates again for the changes to take effect.
$ sudo apt update Hit:1 http://ppa.launchpad.net/vbernat/haproxy-2.5/ubuntu focal InRelease Hit:2 http://mirrors.digitalocean.com/ubuntu focal InRelease Hit:3 http://mirrors.digitalocean.com/ubuntu focal-updates InRelease Hit:4 http://mirrors.digitalocean.com/ubuntu focal-backports InRelease
3. Install HAProxy 2.5
To install the latest HAProxy run the following command on your terminal.
$ sudo apt install haproxy=2.5.\*
Output Reading package lists... Done Building dependency tree Reading state information... Done Selected version '2.5.0-1ppa1~focal' (HAProxy 2.5:20.04/focal [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 1753 kB of archives. After this operation, 4356 kB of additional disk space will be used. Do you want to continue? [Y/n]
Press Y to allow installation to continue
Adding 2.5.\* tells apt tells apt to maintain the latest version of HAProxy.
To check the version of HAProxy installed, use the following command.
$ haproxy -v HAProxy version 2.5.0-1ppa1~focal 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.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64
In this guide we have learned how to install HAProxy 2.5 load balancer on Ubuntu 20.04. For more information you can consult HAProxy rich documentation.