Install and Configure HAProxy Ubuntu 16.04

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 very high traffic websites and powers quite a number of the world’s most visited ones.

Over the years it has become the de-facto standard open source load balancer, is now shipped with most mainstream Linux distributions, and is often deployed by default in a cloud platform.

With this tutorial, you are going to learn how you can install and configure HAProxy on Ubuntu 16.04 step by step.

Install HAProxy

1. Before you download HAProxy you need to update all your system packages by the below command.

sudo apt-get update

2. Run the below command to install HAProxy.

sudo apt-get install haproxy

Type “Y” and press Enter to continue.

3. Once the installation is done successfully, you can make sure of that by running the below command on the terminal to ensure that HAProxy is working.

haproxy -v

Configure HAProxy

1.The first thing you must do is add an entry for HAProxy and each of the web servers to HAProxy.local’s /etc/ hosts file, Open that file with the command

sudo nano /etc/hosts

2. Add for example your servers IP address, and then save and close the file by pressing CTRL + X, and type “Y” to confirm your edits.

3. Start HAProxy to run with boot, run the below command in the terminal and add the below line under the “#CONFIG=” option.

sudo nano /etc/default/haproxy


4. Now start the service by the below command.

sudo service haproxy start


After this tutorial, you should be able to know how you can install HAProxy and also be able to configure it very easily.


I started this tech blog back in 2011 as a place to write down processes I took to fix my client systems and network. Now I write some tips and tricks to help others with the tech issues that one might encounter.

You may also like...