nginx 后端获取真实ip

nginx前端配置

server {
listen 80;
server_name blog.jinchuang.org;

access_log logs/blog.access.log;
error_log logs/blog.error.log;
location / {
proxy_pass http://dis ;
                    proxy_set_header Host $host;
                    proxy_set_header X-Real-IP $remote_addr; 
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

 

后端nginx配置

server {
listen 80;
server_name blog.jinchuang.org;
access_log logs/blog.access.log;
error_log logs/blog.error.log;
location / {

root html;
index index.php;
}

#获取真实ip
set_real_ip_from 192.168.0.0/24;  #前端主机的ip段或主机ip
real_ip_header X-Real-IP;
real_ip_header X-Forwarded-For;


location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
error_page 404 http://www.jinchuang.org/404.html;

}




      本文转自无形于有形  51CTO博客,原文链接:http://blog.51cto.com/jinchuang/1844463,如需转载请自行联系原作者


上一篇:推荐四款可视化工具,解决99%的可视化大屏需求


下一篇:8 种方案解决重复提交问题!你选择哪一种呀?