Apache获取Nginx前端代理真实ip


Apache获取Nginx前端代理真实ip

mod_rpaf : https://github.com/gnif/mod_rpaf/
可用于 Apache2.2版本

mod_remoteip : Apache2.4 版本自带模块

下面这个 mod_remoteip 是可以用于Apache 2.2 的移植版本
https://github.com/ttkzw/mod_remoteip-httpd22

安装 mod_remoteip-httpd22

> cd apache/modules

> wget https://github.com/ttkzw/mod_remoteip-httpd22/raw/master/mod_remoteip.c

> apache/bin/apxs -i -c -n mod_remoteip.so mod_remoteip.c

在httpd.conf里面添加
LoadModule remoteip_module modules/mod_remoteip.so

RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 127.0.0.1

在nginx.conf里面添加

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

参考
https://www.cnblogs.com/itfenqing/p/5934961.html

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注