Wednesday, December 15, 2010

Apache web server load balancing using Pound

Pound is a reverse-proxy load balancing server. It accepts requests from HTTP / HTTPS clients and distributes them to one or more Web servers. The HTTPS requests are decrypted and passed to the back-ends as plain HTTP. It will act as:
a) Server load balancer
b) Reverse proxy server
c) Apache reverse proxy etc
d) It can detects when a backend server fails or recovers, and bases its load balancing decisions on this information: if a backend server fails, it will not receive requests until it recovers
e) It can decrypts https requests to http ones
f) Rejects incorrect requests
h) It can be used in a chroot environment (security feature)

If more than one back-end server is defined, Pound chooses one of them randomly, based on defined priorities. By default, Pound keeps track of associations between clients and back-end servers (sessions).

Install Pound Software

If you are using RHEL / CentOS, grab pound rpm here and type the command:
# rpm -ivh pound*
If you are using FreeBSD, enter:
# cd /usr/ports/www/pound/ && make install clean

How it works?

  • Let us assume your public IP address 202.54.1.5
  • Pound will run on 202.54.1.5 port 80
  • It will forward all incoming http requests to internal host 192.168.1.5 and 192.168.1.10 port 80 or 443
  • Pound keeps track of associations between clients and back-end servers

Pound Configuration

Forward all incoming request at 202.54.1.5 port 80 request to 192.168.1.5 Apache server running at 8080 port:
Open /etc/pound/pound.cfg file:
# vi /etc/pound/pound.cfg

Following example will distribute the all HTTP/HTTPS requests to two Web servers:
ListenHTTP
Address 202.54.1.5
Port 80
End

ListenHTTPS
Address 202.54.1.5
Port 443
Cert "/etc/ssl/local.server.pem"
End
Service
BackEnd
Address 192.168.1.5
Port 80
Priority 6
End
BackEnd
Address 192.168.1.6
Port 8080
End
End


Save and close the file. Restart pound:

# /etc/init.d/pound restart

Pound log file

By default pound log message using syslog:
# tail -f /var/log/messages
# grep pound /var/log/messages

No comments:

Post a Comment