CentOS Stream 8
Sponsored Link

Pound : HTTP を負荷分散2021/03/17

 
HTTP/HTTPS 負荷分散ソフトウェア Pound をインストールします。
当例では以下のような環境を例に設定します。
-----------+---------------------------+--------------------------+------------
           |                           |                          |
           |10.0.0.30                  |10.0.0.51                 |10.0.0.52
+----------+-----------+   +-----------+----------+   +-----------+----------+
|   [ dlp.srv.world ]  |   | [ node01.srv.world ] |   | [ node02.srv.world ] |
|         Pound        |   |      Web Server#1    |   |      Web Server#2    |
+----------------------+   +----------------------+   +----------------------+

 
Pound をインストールしたサーバーへの HTTP 通信をバックエンドの Web Server#1, Web Server#2 へ負荷分散するように設定します。
[1] Pound をインストールします。
# EPEL からインストール

[root@dlp ~]#
dnf --enablerepo=epel -y install Pound
[2] Pound の設定です。
[root@dlp ~]#
mv /etc/pound.cfg /etc/pound.cfg.org

[root@dlp ~]#
vi /etc/pound.cfg
User "pound"
Group "pound"
# ログレベル (5 が最大)
LogLevel 3
# ログの出力先
LogFacility local1
# ハートビートを送る間隔 (秒)
Alive 30

# フロントエンドを定義
ListenHTTP
    Address 0.0.0.0
    Port 80
End

# バックエンドを定義
Service
    BackEnd
        # バックエンドサーバーの IP アドレス
        Address  10.0.0.51
        # バックエンドサーバーの待ち受けポート
        Port     80
        # 優先度を指定 (1-9 で指定 (9 が最優先))
        Priority 5
    End

    BackEnd
        Address  10.0.0.52
        Port     80
        Priority 5
    End
End

[root@dlp ~]#
systemctl enable --now pound

[3] Firewalld を有効にしている場合は、Pound が待ち受けるポートの許可が必要です。
[root@dlp ~]#
firewall-cmd --add-service=http --permanent

success
[root@dlp ~]#
firewall-cmd --reload

success
[4] 指定したファシリティのログが取得できるように Rsyslog の設定を変更します。
[root@dlp ~]#
vi /etc/rsyslog.conf
# 46行目:以下のように変更

*.info;mail.none;authpriv.none;cron.none;local1.none    /var/log/messages
local1.*                                                /var/log/pound.log

[root@dlp ~]#
systemctl restart rsyslog

[5] バックエンド Webサーバー (Apache httpd の場合) で X-Forwarded-For ヘッダーをロギングするよう設定しておきます。
[root@node01 ~]#
vi /etc/httpd/conf/httpd.conf
# 199行目:以下のように変更

LogFormat "
\"%{X-Forwarded-For}i\"
%l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
[root@node01 ~]#
systemctl restart httpd

[6] 任意のクライアントコンピューターから Pound フロントエンドサーバーへ HTTP アクセスして動作を確認しておきます。
関連コンテンツ