Nginx show how real ip

Original link: http://www.cnblogs.com/mjorcen/p/4055328.html
nginx reverse proxy to do the display always shows the real ip 127.0.0.1 backstage access
Just add the following:
 
proxy_set_header Host $host; 
proxy_set_header X-Forwarded-For $remote_addr; 
If you are a java file jsp environment to be detected
 
<% 
out.println("your IP: " + request.getHeader("x-forwarded-for")); 
%> 
You can see the real ip access 192.168.0.215/ip.jsp
In fact, in addition to the configuration of the reference Zhang Yan also
Such as:
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
These can be used, it can display real ip.
The above is for use in urgent need of a friend.

Reproduced in: https: //www.cnblogs.com/mjorcen/p/4055328.html

Guess you like

Origin blog.csdn.net/weixin_30432179/article/details/94784791