LoginSignup
8
8

More than 5 years have passed since last update.

Elastic Load Balancerの配下にApacheをぶら下げたときのログ設定

Last updated at Posted at 2013-01-09

Apacheに限らずですが、ELBを通すとApacheへのアクセスにアクセス元ではなく、ELBのアドレスが記録されてしまいます。

でも、ELBからのApacheへのアクセス時はX-Forwarded-Forヘッダにアクセス元のIPが記録されるため以下のようにしてやることで記録が可能。

httpd-vhost.conf
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D %{X-Forwarded-For}i %{X-Forwarded-Proto}i" elb-combined
CustomLog "/path/to/shared/log/access.log" elb-combined
  • X-Forwarded-For: 接続元IP
  • X-Forwarded-Proto: 接続元メソッド (ELBがSSL Terminatorになっている場合はhttps / 通常はhttp)

ログフォーマットは適当にカスタマイズしてやるといいです。後はログをfluentd等に突っ込んでおけば解析も簡単ですね。

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8