• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to Install HAproxy Load Balancer in Ubuntu

806

How to Install HAproxy Load Balancer in Ubuntu

HAProxy is an open source TCP and HTTP load balancer and a proxy software used in Linux distributions. It distributes the workload among multiple servers to improve the performance of the servers. This article explains the installation process of the HAProxy Load Balancer in Ubuntu.


Installation of HAproxy Load Balancer

Before installing HAproxy, add the required package into repository.

root@linuxhelp:~# add-apt-repository ppa:vbernat/haproxy-1.6
 HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It is particular
.
.
.
gpg: key 1C61B9CD: public key " Launchpad PPA for Vincent Bernat"  imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK

Utilize the following command to update the machine.

root@linuxhelp:~# apt-get update
Hit http://in.archive.ubuntu.com wily InRelease
Get:1 http://security.ubuntu.com wily-security InRelease [65.9 kB]             
Get:2 http://ppa.launchpad.net wily InRelease [15.4 kB]                        
.
.
.
Get:38 http://security.ubuntu.com wily-security/universe Translation-en [37.4 kB]
Fetched 1,912 kB in 19s (97.3 kB/s)                                            
Reading package lists... Done

Now its time to install the HAproxy package.

root@linuxhelp:~# apt-get install haproxy
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  liblua5.3-0
.
.
.
Processing triggers for libc-bin (2.21-0ubuntu4) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (225-1ubuntu9) ...

The ' -v' option used to check the version of HAproxy.

root@linuxhelp:~# haproxy -v
HA-Proxy version 1.6.7 2016/07/13
Copyright 2000-2016 Willy Tarreau < willy@haproxy.org> 

Use the below command to take the original HAproxy configuration file.

root@linuxhelp:~# cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.original

Open the HAproxy configuration file and add content into the entry as shown below,

root@linuxhelp:~# vim /etc/haproxy/haproxy.cfg
frontend http_front
   bind *:80
   stats uri /haproxy?stats
   default_backend http_back

backend http_back
   balance      roundrobin
   server wbs1.com      192.168.5.155:80 check
   server wbs2.com      192.168.5.147:80 check

Once the HAproxy is configured, restart the service.

root@linuxhelp:~# service haproxy restart

Open the web browser with the HAproxy IP to check the status of web-servers.

HAproxy-Load-Balancer-Open

Now you can access the web-server with IP address of Load Balancer. Also can view content of the backend webservers by each and every request.

HAproxy-Load-Balancer-webserver1

HAproxy-Load-Balancer-webserver2

Again open the configuration file of HAproxy and add the following line for authentication.

root@linuxhelp:~# vim /etc/haproxy/haproxy.cfg
listen stats
   bind *:8800
   stats enable
   stats uri /
   stats realm Haproxy Statistics
   stats auth admin:12345

Once the above process is completed, estart the HAproxy service .

root@linuxhelp:~# service haproxy restart

Now open the Browser with the Load Balacer IP and assigned port number. Enter the following credentials as follows,

HAproxy-Load-Balancer-credentials

HAproxy-Load-Balancer-IP-port-number

Tags:
oliver
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

is possible to configure HAProxy Load Balancer in Nginx?

A

follow this link : "https://www.linuxhelp.com/how-to-configure-load-balancer-with-haproxy-for-nginx-in-centos/ "

Q

is any one know how to install CROSSROADS Load Balancer?

A

follow this Link : " https://www.linuxhelp.com/set-xr-crossroads-load-balancer-linux/ "

Q

how to Load balance using nginx ?

A

follow this link : " https://www.linuxhelp.com/how-to-configure-nginx-load-balancer-ubuntu/ "

Q

What is HAProxy used for?

A

HAproxy is used by RightScale for load balancing in the cloud. HAProxy is installed with RightScale load balancer ServerTemplates.

Q

What are Haproxy and Keepalived?

A

Keepalived and HAProxy. Keepalived is a routing software designed to provide simple and robust facilities for load balancing and high-availability to Linux systems and Linux-based infrastructures.

Related Tutorials in How to Install HAproxy Load Balancer in Ubuntu

Related Tutorials in How to Install HAproxy Load Balancer in Ubuntu

How to Configure Nginx as a Reverse Proxy in CentOS
How to Configure Nginx as a Reverse Proxy in CentOS
Nov 26, 2016
How to Configure HAproxy Load Balancer with Keepalived in CentOS
How to Configure HAproxy Load Balancer with Keepalived in CentOS
Nov 21, 2016
How to install Webmin in OpenSUSE
How to install Webmin in OpenSUSE
Nov 7, 2016
How to create virtual host in NGINX (Both Name and IP based)
How to create virtual host in NGINX (Both Name and IP based)
Jul 18, 2016
How to Compile Squid Proxy Server 4.7v on CentOS 7.6
How to Compile Squid Proxy Server 4.7v on CentOS 7.6
Jun 14, 2019
How to Configure Reverse Proxy with HAProxy in CentOS
How to Configure Reverse Proxy with HAProxy in CentOS
Jan 25, 2017
How to create and setup LUNs using LVM
How to create and setup LUNs using LVM
Jun 1, 2016
How to Install and Configure Squid Proxy in Ubuntu 20.4.1
How to Install and Configure Squid Proxy in Ubuntu 20.4.1
Nov 28, 2020

Related Forums in How to Install HAproxy Load Balancer in Ubuntu

Related Forums in How to Install HAproxy Load Balancer in Ubuntu

Apache
elijah class=
What is the difference between httpd and apache
Feb 18, 2017
Linux Monitoring tool
luke class=
how to monitor haproxy using nagios
Jun 15, 2018
HTTP
benjamin class=
400 Bad Request: The plain HTTP request was sent to HTTPS port
Nov 12, 2021
Squid
david class=
htpasswd: command not found
Sep 26, 2017
Browser
james class=
how to access website from command-line to check http response
Feb 7, 2017
Apache
lincoln class=
Apache user authentication using .htaccess
Oct 4, 2017
Python
carter class=
Cant able to view output in browser - python simpleHTTPServer
Apr 7, 2017
Proxy server
ethenjames class=
Adding proxy server in Windows7 environmental variable
Nov 22, 2017

Related News in How to Install HAproxy Load Balancer in Ubuntu

Related News in How to Install HAproxy Load Balancer in Ubuntu

Despite ISP Opposition, All Major Browsers will Eventually Roll Out DNS-over-HTTPS
Despite ISP Opposition, All Major Browsers will Eventually Roll Out DNS-over-HTTPS
Nov 12, 2019
Cisco patches two major security flaws
Cisco patches two major security flaws
May 18, 2019
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Ryan ?
how to use visual traceroute tool

Am using traceroute command to check for the route. i got this tool while surfing. So pls help me out installation and usage of Visual traceroute tool.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.