{"id":3603,"date":"2019-07-13T00:06:14","date_gmt":"2019-07-12T21:06:14","guid":{"rendered":"https:\/\/kifarunix.com\/?p=3603"},"modified":"2020-06-06T09:55:11","modified_gmt":"2020-06-06T06:55:11","slug":"configure-haproxy-with-ssl-on-ubuntu-18-04-debian-10-9","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/configure-haproxy-with-ssl-on-ubuntu-18-04-debian-10-9\/","title":{"rendered":"Configure HAProxy Load Balancer with SSL on Ubuntu 18.04\/Debian 10\/9"},"content":{"rendered":"\n

In this guide, we are going to learn how to configure HAProxy load balancer with SSL on Ubuntu 18.04\/Debian 10\/9. HAProxy<\/a> is the de-factor opensource solution providing very fast and reliable high availability, load balancing and proxying for TCP and HTTP-based applications. As such, HAProxy is suited for very high traffic web sites.<\/p>\n\n\n\n

Configure HAProxy Load Balancer with SSL on Ubuntu 18.04\/Debian 10\/9<\/h2>\n\n\n\n

In this guide, we are going to demonstrate how HAProxy performs load balancing using three web servers serving simple html pages. Our architecture looks like in the diagram below;<\/p>\n\n\n\n

\"Configure<\/a><\/figure><\/div>\n\n\n\n

Install HAProxy on Ubuntu 18.04\/Debian 10\/Debian 9<\/h3>\n\n\n\n

Run system update.<\/p>\n\n\n\n

apt update\napt upgrade<\/code><\/pre>\n\n\n\n

Once the update is done, proceed to install HAProxy on your Ubuntu\/Debian systems.<\/p>\n\n\n\n

Create HAProxy Repository<\/h3>\n\n\n\n

There are different HAProxy packages for each system. Hence, you need to create dedicated repository for each system.<\/p>\n\n\n\n

Before you can create the repos, install the APT signing Key.<\/p>\n\n\n\n

apt install curl -y\ncurl https:\/\/haproxy.debian.net\/bernat.debian.org.gpg | apt-key add -<\/code><\/pre>\n\n\n\n

Next, create HAProxy repositories. On Debian 10 Buster\/Debian 9 Stretch, run the command below to create the repo.<\/p>\n\n\n\n

echo \"deb http:\/\/haproxy.debian.net $(lsb_release -cs)-backports-2.0 main\" | tee \/etc\/apt\/sources.list.d\/haproxy.list<\/code><\/pre>\n\n\n\n

On Ubuntu 18.04, you need to add the vbernat haproxy PPA repos as shown below;<\/p>\n\n\n\n

apt install software-properties-common\nadd-apt-repository ppa:vbernat\/haproxy-2.0<\/code><\/pre>\n\n\n\n

Once the repos are created on each system, perform system update and install HAProxy.<\/p>\n\n\n\n

apt update\napt install haproxy=2.0.\\*<\/code><\/pre>\n\n\n\n

To check the version of installed HAProxy, run the command below;<\/p>\n\n\n\n

haproxy -v<\/code><\/pre>\n\n\n\n
HA-Proxy version 2.0.1-1~bpo9+1 2019\/06\/27 - https:\/\/haproxy.org\/<\/code><\/pre>\n\n\n\n

Configure HAProxy Load Balancer on Ubuntu 18.04\/Debian 10\/9<\/h3>\n\n\n\n

Configuration of HAProxy is all about where it is listening for connection requests and where to forward such requests to. It is therefore made up of frontend system and one or more back-end systems. The front-end system defines the IP address and port on which the proxy listens as well as the back-end systems to use for a particular proxy.<\/p>\n\n\n\n

The main configuration file for HAProxy is \/etc\/haproxy\/haproxy.cfg<\/strong>.<\/p>\n\n\n\n

The HAProxy configuration file is made up of four sections;<\/p>\n\n\n\n