How to Configure Load Balancer with Pound in Ubuntu

To Configure Load Balance with Pound in Ubuntu

Pound is an open source lightweight software for reverse proxy and load balancing solution. As a reverse-proxy load balancing server, it allows the requests from the HTTP/HTTPS clients and distributes them to more than one Web servers. This article explains the configuration of Load balancer with Pound in Ubuntu.

Testing Environment

IP Address Hostname
Pound Load Balancer 192.168.5.145 node1.example.com
Apache Webserver 1 192.168.5.146 node2.example.com
Apache Webserver 2 192.168.5.147 node3.example.com


Pre-requisties

Provide hostname resolution between the three machines either configure DNS server or create entry in /etc/hosts file.

192.168.5.145 node1.example.com node1
192.168.5.146 node2.example.com node2
192.168.5.147 node3.example.com node3

Install Apache package on both of the web servers and configure basic Apache webserver with simple index.html file.

Installation of Pound package

First install the pound package on load balancer machine (node 1).

root@node1:~# apt-get install pound -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  pound
0 upgraded, 1 newly installed, 0 to remove and 435 not upgraded.
.
.
.

Preparing to unpack .../pound_2.6-6.1_amd64.deb ...
Unpacking pound (2.6-6.1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...
Setting up pound (2.6-6.1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...


Create a new configuration file for pound and edit it as follows,

root@node1:~# mv /etc/pound/pound.cfg /etc/pound/pound.cfg.backup
root@node1:~# vim /etc/pound/pound.cfg

Entry:

User " www-data" 
Group " www-data" 
# log level (max: 5)
LogLevel 3
# specify LogFacility
LogFacility local1
# interval of heartbeat - seconds
Alive 30
Control " /var/run/pound/poundctl.socket" 

# define frontend
ListenHTTP
    Address 0.0.0.0
    Port 80
End

# define backend
Service
    BackEnd
        Address  192.168.5.146
        Port     80
        Priority 5
    End

    BackEnd
        Address  192.168.5.147
        Port     80
        Priority 5
    End
End


Once the pound is configured, start and enable its service.

root@node1:~# sed -i -e " s/^startup=0/startup=1/"  /etc/default/pound 
root@node1:~# systemctl start pound 


In addition, you need to configure rsyslog for pound.

root@node1:~# vi /etc/rsyslog.d/50-default.conf
Entry:
#in line 9 change the entry as shown like below and add new line content on line 10
*.* auth,authpriv.none local1.none              -/var/log/syslog     
local1.*                        /var/log/pound.log 


Restart rsyslog service to take effect.

root@node1:~# systemctl restart rsyslog


Now its time to check the load balancer between the webserver nodes from web browser. Open the web browser with the IP address of the pound server.

For each and every request will be redirected to the different webservers.

FAQ
Q
Why load balancer is required?
A
Load balancer is "a device that acts as a reverse proxy and distributes network or application traffic across a number of servers.
Q
Is Pound opensource?
A
The pound is an open source lightweight software for reverse proxy and load balancing solution.
Q
What is Pound software?
A
A pound is an open source lightweight software for reverse proxy and load balancing solution. As a reverse-proxy load balancing server, it allows the requests from the HTTP/HTTPS clients and distributes them to more than one Web servers.
Q
Maybe I'm missing something here but why use pound when load balancing is already built into PfSense?
A
Basically, the load balancer in pfSense is a layer 4 load balancer (it only works on IP). Pound is a layer-7 LB that is able to understand the contents of the packets and able to decrypt it.
Q
pound load balancer slowed my site down?
A
It actually turned out to be an internal DNS issue. Fix resolv.conf on the DNS server and the site sprang to life.