Apacheのアクセスログへリクエスト元ポート番号まで記録する
第39回 大規模NATによるアクセスログの扱い方の変化
http://gihyo.jp/admin/serial/01/whats_inet/0039
「大規模NAT環境ではクライアントのポート番号まで記録しておきましょう」というお話。
このための設定は次の通り。
■検証環境
Apache/2.2.15
■フォーマット
設定には、mod_log_configの下記フォーマットを追記する
%{format}p The canonical port of the server serving the request or the server's actual port or the client's actual port. Valid formats are canonical, local, or remote.
■設定手順
# cd /etc/httpd/conf # cp -p httpd.conf httpd.conf.20120222 # vi httpd.conf # diff -wb httpd.conf.20120222 httpd.conf 509,510c509,511 < LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined < LogFormat "%h %l %u %t \"%r\" %>s %b" common --- > LogFormat "%h:%{remote}p %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined > LogFormat "%h:%{remote}p %l %u %t \"%r\" %>s %b" common # # httpd -t Syntax OK # # /etc/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] #
■参照
mod_log_config - Apache HTTP Server
http://httpd.apache.org/docs/2.2/en/mod/mod_log_config.html
Logging Remote Port Numbers in the Apache HTTP Server for Carrier Grade NAT
http://draft.scyphus.co.jp/articles/20110815.html
以上