====== 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/
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
===== ログ形式変更 =====
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
{{tag>日記 Cloudflare}}