Install Pound – Apache Load balancer – Ubuntu 14.04 / 15.04 / CentOS 7 / Fedora 22

0
Install pound - Apache Load balancer - CentOS 7
Install pound – Apache Load balancer – CentOS 7

Load balancing is the method of distributing the web requests that comes from internet to multiple internal servers, those servers serves the same content to clients. Pound is one of the package that helps you to setup the load balancing for the web server, it provides reverse proxy, and also supports HTTPS requests.

1. When the clients request web content over internet, requests goes to the Pound Gateway ( Public Main Server) 102.108.12.10 at port no 80 or 443.

2. Pound gateway already configured with internal apache web service (192.168.12.11 and 192.168.12.12)

3. Pound gateway forwards all queries to internal servers port no 80 or 443.

4. Pound gateway will do reverse proxy to deliver web content back to clients.

Cotents:

  1. Install Web Server
  2. Install Pound
  3. Configure Pound
  4. Firewall
  5. Extras
  6. Troubleshooting

Install Web Server:

Install Apache server on both internal server using the yum command.

### Ubuntu 15.04 / Ubuntu 14.04 ### 

$ sudo su -
# apt-get update
# apt-get install apache2

### CentOS 7 / RHEL 7 / Fedora 22 ###

# yum install httpd
# systemctl start httpd.service

Place test index.html under /var/www/html on internal servers.

For 192.168.12.11

echo "This is 192.168.12.11" > /var/www/html/index.html

For 192.168.12.12

echo "This is 192.168.12.12" > /var/www/html/index.html

Verify the web servers by visiting http://192.168.12.11 and http://192.168.12.12; you should see “This is 192.168.12.11” and “This is 192.168.12.12” respectively

Install Pound:

Now, install Pound package on the gateway server (102.108.12.10). Pound does not available in CentOS or RHEL 7 base repository, so you need to setup EPEL.

### Only for CentOS 7 / RHEL 7 ###
# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Install Pound rpm.

### Ubuntu 15.04 / Ubuntu 14.04 ###

# apt-get install pound

### CentOS 7 / RHEL 7 / Fedora 22 ###

# yum install Pound

Configure Pound:

pound.cfg is the configuration file and can be found inside /etc directory, open up the configuration file to distribute the requests between two internal servers. If you don’t have SSL certificate installed on the Pound gateway, remove ListenHTTPS stanza.

### Ubuntu 15.04 / Ubuntu 14.04 ###

# nano /etc/pound/pound.cfg

### CentOS 7 / RHEL 7 / Fedora 22 ###

# vi /etc/pound.cfg

Modify the configuration file.

ListenHTTP
    Address 102.108.12.10
    Port 80
End

### Remove below ListenHTTPS stanza, if you do not wish to balance HTTPS request.
ListenHTTPS
    Address 102.108.12.10
    Port    443
    Cert    "/etc/ssl/pound.pem"
End

Service
    BackEnd
        Address 192.168.12.11
        Port    80
    End

    BackEnd
        Address 192.168.12.12
        Port    80
    End
End

Start the Pound service.

### Ubuntu 15.04 / Ubuntu 14.04 ###

# service pound start

### CentOS 7 / RHEL 7 / Fedora 22 ###

# systemctl start  pound.service

Firewall:

Please configure firewall to allow 80 and 443 ports, run the following command.

### CentOS 7 / RHEL 7 / Fedora 22 ###

# firewall-cmd --add-service=http
# firewall-cmd --add-service=https
# firewall-cmd --permanent --add-service=http
# firewall-cmd --permanent --add-service=https
# systemctl restart firewalld

Now visit http://102.102.12.10, refresh the page continuously. You could the see the home page of internal web server, at the same time you can notice that home page continuously changes on every request.

If you are planning to balance HTTPS requests, you mus generate a new certificate for pound, and pound.cfg file has to updated accordingly.

cd /etc/ssl && openssl req -x509 -newkey rsa:1024 -keyout pound.pem -out pound.pem  -days 365 -nodes

Extras:

For Example, if you want to use Pound Gateway as one of the internal web server (102.108.12.10); make Apache web server to listen on some other port instead of port 80, because Pound uses port 80. Below is the small configuration to act as both ( Pound gateway and Web Server). Pound listens on Port 80 at the same time Apache listens on port 808.

ListenHTTP
    Address 102.108.12.10
    Port 80
End

### Remove below ListenHTTPS stanza, if you do not wish to balance HTTPS request.
ListenHTTPS
    Address 102.108.12.10
    Port    443
    Cert    "/etc/ssl/pound.pem"
End

Service
    BackEnd
        Address 102.108.12.10
        Port    808
    End

    BackEnd
        Address 192.168.12.11
        Port    80
    End
End

Troubleshooting:

If you get any error like below,

PID file /var/run/pound.pid not readable (yet?) after start.

Edit the /usr/lib/systemd/system/pound.service file.

vi /usr/lib/systemd/system/pound.service

Comment out PID entrly like below.

#PIDFile=/var/run/pound.pid

Load balancer is the most important solution in enterprise environment where the server gets million’s of requests, it ensures the client to get the web content on time and also free up the load on servers.

You might also like