nginx 安装realip模块


网站部署了流量代理服务(例如Web应用防火墙、DDoS高防、CDN)后,

源站服务器可以通过解析回源请求中的X-Forwarded-For记录,获取客户端的真实IP。

 

1,查看原来nginx的安装模块

./nginx  -V

 没有安装

2,重新编译原来的nginx

cd /tmp/nginx-1.18.0

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --without-http-cache --with-http_ssl_module --with-http_realip_module

make
make install

./nginx -V

 安装成功

3,添加nginx的realip配置

set_real_ip_from 47.101.16.64/27;
real_ip_header X-Forwarded-For;
real_ip_recursive on;

以及 nginx的日志格式在log_format中添加http_x_forwarded_for字段,替换默认的remote_address字段

4,重启nginx

./nginx -s reload

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM