2016年10月17日 星期一

Apache-mod_remoteip (2.4)

Nginx  reverse proxy Apache real IP

yum install httpd-devel

mkdir ~/mod_realip2
cd ~/mod_realip2
wget -O mod_realip2.zip https://github.com/discont/mod_realip2/archive/master.zip
unzip mod_realip2.zip
cd mod_realip2-master
apxs -c -i mod_realip2.c
cp ./centos/realip2.conf /etc/httpd/conf.d

/usr/lib64/httpd/modules/mod_realip2.so

cp ./centos/realip2.conf /etc/httpd/conf.d
/etc/httpd/conf.d/realip2.conf
LoadModule realip2_module modules/mod_realip2.so

RealIP On
RealIPProxy 127.0.0.1 xxx.xxx.xxx.xxx
RealIPHeader X-Real-IP


/etc/nginx/nginx.conf
location / {
    proxy_set_header X-Real-IP $remote_addr;
}

https://httpd.apache.org/docs/current/mod/mod_remoteip.html

log 設定

httpd.conf
Change:
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined

To:
LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined

http://blog.somsip.com/2013/12/apache-2-4-mod_remoteip/


apxs:Error: Command failed with rc=65536

replace remote_ip client_ip -- mod_realip2.c
replace remote_addr client_addr -- mod_realip2.c

apxs -i -c -n mod_realip2.so mod_realip2.c

http://wiki.iphoster.ru/wiki/Apache_-_mod_realip2_%D0%BE%D1%88%D0%B8%D0%B1%D0%BA%D0%B0_has_no_member_named_'remote_addr'_and_'remote_ip'

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。