nginx记录真是的IP地址 <备忘>
2015-08-06 10:39
549 查看
nginx、haproxy等作为代理服务器时,要使后端web服务器记录真是的IP地址,需要配置:
nginx:
将:
location / { 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_buffering off; proxy_pass http://bloke; }后端web服务器配置:
nginx:
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';apache:
将:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined改为:
LogFormat "%{X-Real-IP}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
相关文章推荐
- Nginx+Apache配置详解
- Visual NMP中升级Nginx、PHP、MySQL
- Linux深入篇之一:配置Nginx Web服务器及多域名主机
- 确保nginx安全,请注意这10点
- Nginx配置文件nginx.conf中文详解
- Ubuntu14.04 下安装配置php5和nginx问题解决
- Nginx之location
- Nginx 笔记与总结(8)Location:归纳总结
- nginx的学习笔记
- nginx 进行外网地址屏蔽
- ElasticSearch:Nginx可以给ElasticSearch集群带来什么福利?
- 测试部署nginx
- Ubuntu 14.10下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具)
- nginx upstream的几种配置方式
- 自己写了个nginx启动脚本,shell
- Nginx(2):工作机制
- PHP nginx 去掉伪静态的配置
- 使用Nginx+FFMPEG搭建HLS直播转码服务器
- Smooth Streaming Module for Nginx
- Nginx基础学习