码迷,mamicode.com
首页 > 其他好文 > 详细

nginx 后端获取真实ip

时间:2016-08-30 22:58:31      阅读:323      评论:0      收藏:0      [点我收藏+]

标签:nginx

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 /usr/local/nginx/blog/wordpress;
index index.php;
}

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

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

}


本文出自 “jinchuang” 博客,请务必保留此出处http://jinchuang.blog.51cto.com/8690689/1844463

nginx 后端获取真实ip

标签:nginx

原文地址:http://jinchuang.blog.51cto.com/8690689/1844463

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!