nginx 获取真实ip配制
2016-05-03 00:00
225 查看
1、传递真实ip给后台
2、获取nginx传递过来的真实ip
需要加一个模块 http_realip_module
重新编译nginx
然后location里配制
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host;
2、获取nginx传递过来的真实ip
需要加一个模块 http_realip_module
重新编译nginx
./configure --prefix=/home/data/nginx --with-http_realip_module make install service nginx restart
然后location里配制
set_real_ip_from 192.168.1.0/24; 指定接收来自哪个前端发送的 IP head 可以是单个IP或者IP段 set_real_ip_from 192.168.2.1; real_ip_header X-Real-IP; service nginx reload
相关文章推荐
- nginx 的基本配置
- ubuntu14.04 LEMP(linux+nginx+mysql+php5)构建环境
- Nginx拷贝流量
- Nginx 之四: Nginx服务器的rewrite、全局变量、重定向和防盗链相关功能
- centos7下添加常用YUM源(EPEL/Remi/RPMforge/php/Nginx)
- nginx OpenResty(nginx扩展)实现防cc攻击 - 为程序员服务
- Nginx之location匹配规则(个人总结)
- 使用nginx和iptables做访问权限控制(IP和MAC)
- nginx+lua tips (一)
- ubuntu 上apt-get 安装 php5.6过程和nginx php-fpm 502 问题
- 基于nginx和uWSGI在Ubuntu上部署Django
- Nginx-location配置指南
- CentOS 7.x PhpMyAdmin Install and Configure with Nginx
- Nginx 之四: Nginx服务器的压缩功能和缓存功能
- Nginx location 配置踩坑过程分享
- Nginx学习以及PHP+Nginx的环境安装与配置
- nginx详细配置说明
- Python运维自动化--nginx配置文件对比
- nginx php-fpm中启用慢日志配置(用于检测执行较慢的PHP脚本)
- 实战Nginx与PHP(FastCGI)的安装、配置与优化