Kill lui lei Dog---linux no:40 the reverse proxy log correction for Linux

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.