How To Install HAProxy on Ubuntu 16.04 LTS

r00t December 30, 2016

Install HAProxy on Ubuntu 16.04 LTS

In this tutorial we will show you how to install and configuration HAProxy on Ubuntu 16.04 LTS. For those of you who didn’t know, HAProxy is a free HTTP/TCP high availability load balancer and proxy server. It spreads requests among multiple servers to mitigate issues resulting from single server failure. HA Proxy is used by a number of high-profile websites including GitHub, Bitbucket, Stack Overflow, Reddit, Tumblr, Twitter and Tuenti and is used in the OpsWorks product from Amazon Web Services.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation HAProxy on a Ubuntu 16.04 (Xenial Xerus) server.

Install HAProxy on Ubuntu 16.04 LTS

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

Step 2. Network Details.

Below is our network server. There are 3 web servers running with Apache2 and listening on port 80 and one HAProxy server:

Step 3. Installing HAProxy.

Now install HAProxy with the following command:

After the installation you can double check the installed version number with the following:

Step 4. Configuring HAProxy.

We have to modify the configuraion file of haproxy i.e. /etc/haproxy/haproxy.cfg as per our requirement. (Change this configuration as your network requirements). For more configuration details check this url.

Since you have done with all necessary configurations for proxy server, verify configuration file before restarting service using following command:

If above command return output as “configuration file is valid” then restart HAProxy service:

Step 5. Accessing HAProxy.

Open your favorite browser and access port 80 on ip 192.168.0.16 (as configured above) in web browser and hit refresh. You will see that HAProxy is sending requests to backend server one by one (as per round robin algorithm).

Congratulation’s! You have successfully installed HAProxy. Thanks for using this tutorial for installing HAProxy load balancing on Ubuntu 16.04 LTS  (Xenial Xerus) system. For additional help or useful information, we recommend you to check the official HAProxy web site.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get a best deal!

Save

Save

Share on Google+0Share on Facebook0Tweet about this on TwitterShare on Tumblr0Share on StumbleUpon1Share on Reddit1Pin on Pinterest3
The Tags:

Leave a Comment