nginx中获取真实ip

nginx反向代理配置时,一般会添加下面的配置:

      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header REMOTE-HOST $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

 

location / {

   proxy_pass http://127.0.0.1:10678;

   proxy_set_header Host $host;

        proxy_set_header X-Real-IP $remote_addr;

        proxy_set_header REMOTE-HOST $remote_addr;

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }


这样就ok了。

posted @ 2016-09-05 12:48  爱你爱自己  阅读(10705)  评论(0编辑  收藏  举报