Ubuntu 14.04
Sponsored Link

Pound : HTTP Load Balancing2016/01/11

 
Install Pound which is HTTP/HTTPS Load Balancing software.
This example is based on the environment like follows.
        |
--------+--------------------------------------------------------------------
        |
        +-------------------+--------------------+--------------------+
        |10.0.0.30          |10.0.0.51           |10.0.0.52           |10.0.0.53
 +------+-----+     +-------+------+     +-------+------+     +-------+------+
 |  Frontend  |     |   Backend#1  |     |   Backend#2  |     |   Backend#3  |
 |   Pound    |     |  Web Server  |     |  Web Server  |     |  Web Server  |
 +------------+     +--------------+     +--------------+     +--------------+

 
Configure Pound to load balance to Backend#1, Backend#2, Backend#3 web servers.
[1] Install Pound.
root@dlp:~#
apt-get -y install pound
[2] Configure Pound.
root@dlp:~#
mv /etc/pound/pound.cfg /etc/pound/pound.cfg.org

root@dlp:~#
vi /etc/pound/pound.cfg
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
       # backend server's IP address

        Address  10.0.0.51
       # backend server's port

        Port     80
       # set priority (value of 1-9, max 9)

        Priority 5
    End

    BackEnd
        Address  10.0.0.52
        Port     80
        Priority 5
    End

    BackEnd
        Address  10.0.0.53
        Port     80
        Priority 5
    End
End

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

root@dlp:~#
/etc/init.d/pound restart

[3] Change Rsyslog setting to revord logs from Pound.
root@dlp:~#
vi /etc/rsyslog.d/50-default.conf
# line 9: change and add like follows

*.*;auth,authpriv.none;local1.none              -/var/log/syslog
local1.*                        /var/log/pound.log

root@dlp:~#
initctl restart rsyslog

[4] Change Apache2 settings on Backend Web servers to record logs of X-Forwarded-For.
root@node01:~#
a2enmod remoteip

Enabling module remoteip.
To activate the new configuration, you need to run:
  service apache2 restart

root@node01:~#
vi /etc/apache2/apache2.conf
# line 206-209: change like follows

# specify Pound server's IP address for RemoteIPInternalProxy

RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 10.0.0.30

LogFormat "%v:%p
%a
%l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "
%a
%l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
root@node01:~#
/etc/init.d/apache2 restart

 * Restarting web server apache2
   ...done.
[5] Make sure it works fine to access to the frontend server from a Client with HTTP like follows.
Matched Content