PoundでSSL

Pound でSSLラッパする方法をメモしておきます。
参考サイト:@IT


開発環境などで、なんちゃってSSL環境が必要な場合、簡単に設定できちゃいます。
(本番運用では、OpenSSL / mod_ssl などのSSLモジュールを使用し、正当な認証局から発行されたSSL Keyで実装しませう。)



■ソースファイルを取得〜インストール
cd /usr/local/src
wget http://www.apsis.ch/pound/Pound-2.0.6.tgz
tar xvfz Pound-2.0.6.tgz
cd Pound-2.0.6
./configure
make
make install


■証明書の作成
cd /usr/local/etc
openssl genrsa -des3 -out server-key.pem 1024
パスフレーズ入力(自由に)


openssl rsa -in server-key.pem -out server-key.pem
openssl req -new -key server-key.pem -x509 -out pound.pem


:パスフレーズ
:国名:JP
:県名:(Enter)
:市名:(Enter)
:組織名:HOGEHOGE
:サブ組織名:(Enter)
:共通名:(Enter)
:e-mail:(Enter)
  (Enter はデフォルトになるらしい)


// パスフレーズを書き込んだ秘密鍵ファイルでPound用のサーバ証明書を完成させる
cat server-key.pem >> pound.pem



■設定ファイルを作成
// 以下の内容のファイルを作成
vi pound.cfg


#LogLevel value
# Specify the logging level: 0 for no logging, 1 (default) for regular logging, 2
# for extended logging (show chosen backend server as well), 3 for Apache-like
# format (Common Log Format with Virtual Host) and 4 (same as 3 but without the
# virtual host information).
LogLevel 0


#Alive value
# Specify how often Pound will check for resurected back-end hosts (default: 30
# seconds). In general, it is a good idea to set this as low as possible - it will
# find resurected hosts faster. However, if you set it too low it will consume
# resources - so beware.
Alive 10


#LogFacility value
# Specify the log facility to use. value (default: daemon) must be one of the sym-
# bolic facility names defined in syslog.h. This facility shall be used for log-
# ging (if Pound was compiled with support for syslog).
#LogFacility daemon


ListenHTTPS
Address 192.168.1.1
Port 443
Cert "/usr/local/etc/pound.pem"


AddHeader "X_SSL: pound"
Service
BackEnd
Address 192.168.1.1
Port 443
End
End
End



■起動Shellの作成
cd /etc/rc.d/init.d

以下の内容のファイルを作成
vi pound


#! /bin/sh
#
# chkconfig:35 90 25
#
# /etc/rc.d/init.d/pound
#
### BEGIN INIT INFO
# Provides: pound
# Required-Start: $network $syslog
# Required-Stop:
# Default-Start: 3 5
# Default-Stop:
# Description: Starts pound reverse proxy
### END INIT INFO

POUND_BIN=/usr/local/sbin/pound
POUND_PID=/var/run/pound.pid
POUND_CONF=/usr/local/etc/pound.cfg

if [ ! -x $POUND_BIN ] ; then
echo -n "Pound not installed ! "
exit 5
fi

. /etc/rc.d/init.d/functions

RETVAL=0

case "$1" in
start)
echo -n $"Starting pound "
daemon $POUND_BIN
RETVAL=$?
[ $RETVAL = 0 ] && touch /var/lock/subsys/pound
echo
;;
stop)
echo -n $"Shutting down pound "
killproc $POUND_BIN
RETVAL=$?
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/pound && rm -f $POUND_PID.*
echo
;;
restart)
$0 stop
$0 start
;;
status)
echo -n "Checking for Pound "
status $POUND_BIN
;;*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 1
esac

exit $RETVAL


自動起動設定
chmod 755 pound

cd ../rc3.d
ln -sf ../init.d/pound S84pound

cd ../rc5.d
ln -sf ../init.d/pound S84pound


■Poundの起動
/usr/local/sbin/pound



■Poundのプロセスを確認
ps -aef | grep pound