LoginSignup
1
1

More than 5 years have passed since last update.

AWS ELB remote_ipの採取

Last updated at Posted at 2017-03-09

tl;dr

ELBに紐付いているWebブラウザログにリモートIPを表示させたい。
Apacheのバージョンごとに記載する。

Apache 2.2



Apacheモジュールインストール
git clone git://github.com/ttkzw/mod_rpaf-0.6.git
cd mod_rpaf-0.6/
make
make install
モジュール設定ファイル更新
cd /etc/httpd/conf.d
vi mod_rpaf.conf

※下記、転送経路のリバースプロキシIPを追記
RPAFproxy_ips 172.18.11.100 #ReverseProxy IP
httpd再起動
service httpd configtest
service httpd restart

Apache 2.4


[Web00]
 ec2-54-238-238-100.ap-northeast-1.compute.amazonaws.com
[Web03]
 ec2-54-178-135-10.ap-northeast-1.compute.amazonaws.com

制御参照
[VPC]
 vpc-0exxxxxx
 10.3.0.0/16
[Subnet(Public)]
 CIDR: 10.3.0.0/24
[Subnet(Private)]
 CIDR: 10.3.254.0/24

設定情報

$vi /etc/httpd/conf.modules.d/00-remoteip.conf

LoadModule remoteip_module modules/mod_remoteip.so

RemoteIPHeader x-forwarded-for
RemoteIPProxiesHeader Remote_Addr
RemoteIPTrustedProxy 10.3.0.0/24

httpd再起動

/etc/init.d/httpd restart
WebServerログ追跡

tail -f /var/log/httpd/web-api.hoge.com-access_log.yyyymmdd

付録


.htaccess_mente ファイルの現行記述のうち、下記箇所を書き換えれば要求を満たせました。

[1]アクセス元IPでメンテ除外IPを指定

RewriteCond %{REMOTE_ADDR} !^××.××.××.××
↓
RewriteCond %{HTTP:X-Forwarded-For} !^××.××.××.××
[2]ヘルスチェックファイルは、ELB 503判定除外

RewriteCond %{REQUEST_URI} !^/admin/healthcheck.html

参照

Apache ver.2.4 版
http://iga-ninja.hatenablog.com/entry/2014/08/19/135131

1
1
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
1
1