Pound-2.5.tgzではMakeでエラーするので、Pound-2.6f.tgzをGetしたら問題なかった
pound.h:340: error: expected specifier-qualifier-list before ‘LHASH’ make: *** [pound.o] エラー 1
$ wget http://www.apsis.ch/pound/Pound-2.6f.tgz
Webサーバのロードバランサ(バックProxyとしても)として利用できる。
ここからDownlaodしてくる。
--------------- ----------------
| | | |
| Pound | | Web |
| 10.3.1.50 |================| 10.3.1.51 |
| | | | |
| | | | |
--------------- | ----------------
|
| ----------------
| | |
| | Web |
========| 10.3.1.52 |
| |
----------------
$ tar zxvf Pound-2.1.6.tgz $ cd Pound-2.1.6 $ ./configure --with-ssl=/usr (--with-ssl=ssl_dir OpenSSL home directory) (openssl-develも必要) $ make $ su # make install
pound-1xと-2xではpound.cfgの書式が異なる。今回は-2xで試してみる。
/usr/local/etc/pound.cfgを編集(作成)
User "nobody" <--起動ユーザの指定
Group "nobody" <--起動グループの指定
ListenHTTP
Address 10.3.1.50 <---PoundのIPアドレス
Port 80 <---Poundの受信ポート
xHTTP 2 <---WebDAVを通過させるため(WindowsのWebDAVで確認した)
Service
BackEnd
Address 10.3.1.51
Port 80
Priority 9 <---デフォルトは1 1-9で指定で9がプライオリティが高い
End
BackEnd
Address 10.3.1.52
Port 80
Priority 1
End
End
End
# /usr/local/sbin/pound -cv Config file /usr/local/etc/pound.cfg is OK
#/usr/local/sbin/pound
# ps ax 15268 ? S 0:00 /usr/local/sbin/pound 15269 ? S 0:00 /usr/local/sbin/pound 15270 ? S 0:00 /usr/local/sbin/pound 15271 ? S 0:00 /usr/local/sbin/pound 15272 ? S 0:00 /usr/local/sbin/pound
/var/log/messagesにlogが出るので起動失敗では確認する
poundでSSL接続させるためにサーバキー、公開キーを作成する。Vineの場合すでにApacheで利用されているのでそれを利用する。
# cp /etc/httpd/conf/ssl.key/server.key server-key.pem
# cp /etc/httpd/conf/ssl.crt/server.crt pound.pem
二つのキーをマージしてpoundでは利用するのでマージする。
# cat server-key.pem >> pound.pem
# openssl genrsa -des3 -out server-key.pem 1024 Generating RSA private key, 1024 bit long modulus .........++++++ .......++++++ e is 65537 (0x10001) Enter pass phrase for server-key.pem:***** Verifying - Enter pass phrase for server-key.pem:*****
# openssl rsa -in server-key.pem -days 365 -out server-key.pem Enter pass phrase for server-key.pem:***** writing RSA key
# openssl req -new -key server-key.pem -x509 -days 365 -out pound.pem You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:JP State or Province Name (full name) [Some-State]:Mie Pref Locality Name (eg, city) []:Matsusaka Organization Name (eg, company) [Internet Widgits Pty Ltd]:MCU Organizational Unit Name (eg, section) []: Common Name (eg, YOUR name) []:localhost Email Address []:student@localhost
二つのキーをマージしてpoundでは利用するのでマージする。
# cat server-key.pem >> pound.pem
以下の内容をpound.cfgに追加すると10.3.1.50にssl接続しに来たら10.3.1.51の ポート80に投げる。
ListenHTTPS
Address 10.3.1.50
Port 443
Cert "/usr/local/etc/pound.pem"
Service
BackEnd
Address 10.3.1.51
Port 80
End
End
End
http://10.3.1.50/51/はhttp://10.3.1.51/51/をアクセスし、http://10.3.1.50/52/はhttp://10.3.1.52/52/をアクセスする。
以下の内容を「単純なリバースプロキシの設定」の前に追加する。 Servceはパターンに合ったものから処理し、先に記入されたものが優先される
Service
URL "/51/.*"
BackEnd
Address 10.3.1.51
Port 80
Priority 1
End
End
Service
URL "/52/.*"
BackEnd
Address 10.3.1.52
Port 80
Priority 1
End
End
アクセスURLを変えてアクセスすると異なるマシンへのアクセスを実現する方法が不明 出来きるのか?
Poundはpound.cfgに記載順に実行されるので、先に指定ディレクトリに転送する方法で記載し、その後デフォルトの転送さきとして以下の指定をする。
(指定ディレクトリの内容) Service Redirect "http://10.3.1.50:8080" End
アクセスするポートによりサーバとポートを指定する
192.yyy.yyy.yyy:8088にアクセスすると192.xxx.xxx.xxx:80にフォワード
ポート8089アクセスすると10.zzz.zzz.zzzz:8080にフォワード
これで一つのマシンがグローバルでアクセスできたらポート指定で
内部サーバにもアクセス可能。
pound.cfg
User "nobody"
Group "nobody"
# 8088ポートの転送先アドレスポート指定
ListenHTTP
Address 192.yyy.yyy.yyy
Port 8088
Service
BackEnd
Address 192.xxx.xxx.xxx
Port 80
Priority 9
End
End
End
# 8089ポートの転送先アドレスポート指定
ListenHTTP
Address 192.yyy.yyy.yyy
Port 8089
Service
BackEnd
Address 10.zzz.zzz.zzz
Port 8080
Priority 9
End
End
End
デフォルトではlogは/var/log/messagesに入る。これを/var/log/pound.logに入れるには syslogを使用して、pound.cfgと/etc/syslog.confに追加する
pound.cfg
User "nobody" Group "nobody" LogFacility local5 <--追加(あいているlocal0〜7のあいているところ) LogLevel 3 <--追加(0〜4が指定できる [emerg〜warning])
/etc/syslog.conf
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none;local5.none /var/log/messages
^^^^^^^^^^^追加:これがないと/var/log/messagesにも記入される
(略)
# Save pound messages to pound.log
local5.* /var/log/pound.log <--追加(local5はpound.cfgに合わせる)
syslogdとpoundを再起動