http://stderr.net/apache/rpaf/download/
编译吗。。用这个
/usr/local/httpd/bin/apxs -i -a -c mod_rpaf-2.0.c
注意他有2个.c的2.0这个是for apache2.0的(文档太烂,我自己猜的,反正没2.0的编译不过去~~)
chmod 755 /usr/local/httpd/modules/mod_rpaf-2.0.so
[activating module `rpaf' in /usr/local/httpd/conf/httpd.conf]
貌似直接就搞上去了。。
RPAFenable On
# Enable reverse proxy add forward
RPAFproxy_ips 127.0.0.1 10.10.70.*
#实际测试中ip他不支持*这种通配符..所以还是写清楚你nginx的原始IP吧!
# which ips are forwarding requests to us
RPAFsethostname On
# let rpaf update vhost settings
# allows to have the same hostnames as in the “real”
# configuration for the forwarding Apache
RPAFheader X-REAL-IP
# Allows you to change which header mod_rpaf looks
# for when trying to find the ip the that is forwarding
# our requests
X-REAL-IP哪里来的呢?当然是nginx里面配置的~~
set $my_x_real_ip “”;
if ($my_x_real_ip ~ “^$”) {
set $my_x_real_ip $http_x_real_ip;
}
if ($http_x_real_ip ~ “^$”) {
set $my_x_real_ip $remote_addr;
}
proxy_set_header X-Real-IP $my_x_real_ip;
吧这个存成realIP.conf然后再nginx的conf里面每个server段include一下,就会多一个x-real-ip的header了
print_r($_SERVER);
[REMOTE_ADDR] => 192.168.105.47
你看,php已经能正常获取IP了!
Recent Comments