Guide: Upgrading HAProxy from 1.6 to 1.8 on Ubuntu 16.04.4 LTS (Xenial).

The other day, I decided that it was time to upgrade my HAProxy load balancer from 1.6 to 1.8. I skipped 1.7 and went straight to 1.8 because it supports HTTP2.

This post details the steps that I took to do this on Ubuntu 16.04.4 LTS (Xenial).

Create a test environment.

First of all, I created a copy of my existing server. I did this by creating a snapshot of my load balancer server. This is extremely important, as it allows you to test the upgrade process before you attempt to do so on a live server. I know that I’m stating the obvious here, but it is much better to encounter configuration errors in a testing environment than it is to encounter them in a live environment.

Note: This article does not offer help on configuration errors or conflicts, so if you ignore the advice above, you are doing so at your own peril.

Backup your HAProxy configuration file.

HAProxy will not overwrite your current configuration file during the upgrade process unless you tell it to do so. However, I’d rather be safe than sorry. It’s better to err on the side of caution and create a backup file, just in case we get clumsy:

Add HAProxy 1.8 to your repository.

I used the PPA by Vincent Bernat:

Once the PPA has been successfully added, run an update:

Upgrade to 1.8.

I upgraded to HAProxy 1.8 by running the following command:

Note: During the upgrade process, I chose the option to keep my current configuration file.

Once the upgrade was complete, I ran a check on the configuration file to see if worked with HAProxy 1.8. On Ubuntu 16.04.4, you can validate the HAProxy configuration file by running the following command:

Fortunately for me, there were no errors. If you do run into issues, then I hope that you took my first point about creating a test environment seriously! Doing the upgrade inside a test environment allows you to solve configuration problems before you attempt to upgrade your live server.

You can confirm that you are running HAProxy 1.8 by using the –version command like so:

If you’re running 1.8, it will say something like “HA-Proxy version 1.8.14-1ppa1~xenial 2018/09/23”.

Adding HTTP2 to HAProxy.

If you’re like me, then you’re probably upgrading to 1.8 so that you can take advantage of its support for HTTP2. To add HTTP2 support to my load balancer, I just changed this line in my haproxy.cfg file from this:

to this:

Notice how I appended alpn h2,http/1.1 onto the end.

After you’ve modified your config file, you can reload HAProxy like so:

Facebook Comments