If we only use the reverse proxy purely, then Server B's log will have a problem:
Our server A is 192.168.155 to access Server B's/logo.png, which is certainly true, the schematic is as follows:
However, we often need to know the real IP from the client, not the IP sent by server A, because it will be more convenient to transport and the promotion of personnel statistics and so on ...
First we change the configuration file for Server A:
Location ~ \. (jpg|jpeg|png| gif) $ { Proxy_set_header X-forwarded-for$remote _addr; Proxy_pass http://192.168.8.166:80; }
Then go back and reset the configuration:
Then go to Server B to modify his configuration file:
Then go to the Sbin directory using the command./nginx-s reload reset the configuration under Server B:
Then go to refresh the page.
Then look at Server B's logs:
Successful completion ...
This is also the industry's small agreement, when the client through the proxy server, to prevent Server B (back-end server) lost the real IP, it is necessary to let server a more than a head of information to the backend server, x-forwarded-for, If the backend server sees x-forwarded-for then he thinks x-forwarded-for IP is the IP of the user.
Kill lui lei Dog---linux no:40 the reverse proxy log correction for Linux