nginx acquired real IP Client Access

date : 2019-06-28 16:54:50

author: headsen chen

notice: personal original

 

1, the basic concepts necessary to first figure out

1.1 What is REMOTE_ADDR
       REMOTE_ADDR server is specified based on ip TCP packet requests. Assuming no intermediate server from the client to any agent, then the web server (Nginx, Apache, etc.) will be set as the client's IP IPremote_addr; if there is a proxy forwards the HTTP request, the web server will last IP proxy server is set remote_addr.
       Without the use of a proxy server:
        REMOTE_ADDR = your IP
        HTTP_VIA = no value or not displayed
        HTTP_X_FORWARDED_FOR = no value or do not show

1.2 What is x_forwarded_for
       when using a proxy, web server can not get the real IP client initiates a request through TCP packet source, so proxy server will usually request header field called x_forwarded_for increase in http, used to record the real initiator of the request IP.

  Using a transparent proxy server: Transparent Proxies
        REMOTE_ADDR = last a proxy server IP
        HTTP_VIA = proxy IP
        HTTP_X_FORWARDED_FOR = your real IP, passes through multiple proxy servers, this value is similar to the following: 203.98.182.163, 203.98.182.163, 203.129. 72.215.
     Such a proxy server or to forward your information to access your objects, not to hide the true identity of purpose.

2, how to configure nginx, so as to obtain the real client IP

 

Call this configuration: which then calls the server configuration.

 

On it

 

Guess you like

Origin www.cnblogs.com/kaishirenshi/p/11103759.html