ユーザ用ツール

サイト用ツール


このページの翻訳:



最近の更新



Tag Cloud

50_dialy:2025:02:18

2025.02.18 mod_remoteip Apache2.2

古いOSでApache2.2が動いている場合、mod_remoteipは利用できない。
※mod_remoteipは、Apache2.4以降

ソースから

cd /usr/local/src/
git clone https://github.com/ttkzw/mod_remoteip-httpd22.git
cd mod_remoteip-httpd22

Apacheに組み込む

apxs -i -c -n mod_remoteip.so mod_remoteip.c

confファイル用意

cp -p mod_remoteip.conf /etc/httpd/conf.d/

Cloudflare用に修正

Apache 2.2 では RemoteIPTrustedProxy が使用できないため、RemoteIPInternalProxyを利用
CloudflareのIPリストは、https://www.cloudflare.com/ja-jp/ips/

/etc/httpd/conf.d/mod_remoteip.conf

LoadModule remoteip_module modules/mod_remoteip.so
RemoteIPHeader CF-Connecting-IP
RemoteIPInternalProxy 127.0.0.1
RemoteIPInternalProxy 173.245.48.0/20
RemoteIPInternalProxy 103.21.244.0/22
RemoteIPInternalProxy 103.22.200.0/22
RemoteIPInternalProxy 103.31.4.0/22
RemoteIPInternalProxy 141.101.64.0/18
RemoteIPInternalProxy 108.162.192.0/18
RemoteIPInternalProxy 190.93.240.0/20
RemoteIPInternalProxy 188.114.96.0/20
RemoteIPInternalProxy 197.234.240.0/22
RemoteIPInternalProxy 198.41.128.0/17
RemoteIPInternalProxy 162.158.0.0/15
RemoteIPInternalProxy 104.16.0.0/13
RemoteIPInternalProxy 104.24.0.0/14
RemoteIPInternalProxy 172.64.0.0/13
RemoteIPInternalProxy 131.0.72.0/22

ログ形式変更

/etc/conf/httpd.conf

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

LogFormat "%a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
50_dialy/2025/02/18.txt · 最終更新: 2025/02/28 16:39 by matsui