How to install HAProxy 1.8 on Ubuntu 16

Install recent HAProxy version to take advantage of the new fancy features.

Install software-properties-common package to use add-apt-repository command.

$ sudo apt-get install software-properties-common

Configure HAProxy 1.8 PPA by Vincent Bernat.

$ sudo add-apt-repository ppa:vbernat/haproxy-1.8
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 1.8.
 More info:
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keyring `/tmp/tmpesm7ss5z/secring.gpg' created
gpg: keyring `/tmp/tmpesm7ss5z/pubring.gpg' created
gpg: requesting key 1C61B9CD from hkp server
gpg: /tmp/tmpesm7ss5z/trustdb.gpg: trustdb created
gpg: key 1C61B9CD: public key "Launchpad PPA for Vincent Bernat" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

Update package index.

$ sudo apt-get update
Hit:1 xenial InRelease
Hit:2 xenial-updates InRelease                                   
Hit:3 xenial-backports InRelease                                 
Get:4 xenial-security InRelease [102 kB]                            
Get:5 xenial InRelease [23.8 kB]                  
Hit:6 icinga-xenial InRelease                               
Get:7 xenial/main amd64 Packages [1,008 B]
Get:8 xenial/main i386 Packages [1,004 B]        
Get:9 xenial/main Translation-en [716 B]         
Fetched 129 kB in 0s (225 kB/s)                     
Reading package lists... Done

Verify available HAProxy versions.

$ apt-cache policy haproxy
  Installed: 1.6.3-1ubuntu0.1
  Candidate: 1.8.2-1ppa1~xenial
  Version table:
     1.8.2-1ppa1~xenial 500
        500 xenial/main amd64 Packages
 *** 1.6.3-1ubuntu0.1 500
        500 xenial-updates/main amd64 Packages
        500 xenial-security/main amd64 Packages
        100 /var/lib/dpkg/status
     1.6.3-1 500
        500 xenial/main amd64 Packages

Upgrade HAProxy package.

$ sudo apt-get install --only-upgrade haproxy
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  vim-haproxy haproxy-doc
The following packages will be upgraded:
1 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Need to get 1,118 kB of archives.
After this operation, 820 kB of additional disk space will be used.
Get:1 xenial/main amd64 haproxy amd64 1.8.2-1ppa1~xenial [1,118 kB]
Fetched 1,118 kB in 0s (3,161 kB/s)
(Reading database ... 67371 files and directories currently installed.)
Preparing to unpack .../haproxy_1.8.2-1ppa1~xenial_amd64.deb ...
Unpacking haproxy (1.8.2-1ppa1~xenial) over (1.6.3-1ubuntu0.1) ...
Processing triggers for systemd (229-4ubuntu21) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up haproxy (1.8.2-1ppa1~xenial) ...
Installing new version of config file /etc/haproxy/errors/500.http ...

Configuration file '/etc/haproxy/haproxy.cfg'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** haproxy.cfg (Y/I/N/O/D/Z) [default=N] ? 
Installing new version of config file /etc/init.d/haproxy ...
Processing triggers for systemd (229-4ubuntu21) ...
Processing triggers for ureadahead (0.100.0-19) ...

Now you can take advantage of the HTTP/2 and other fancy features.

Milosz Galazka's Picture

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system. He is also open for new opportunities and challenges.

Gdansk, Poland