Environment:
user:192.168.100.169
Nginx Agent: 192.168.100.175
tomcat:192.168.100.175
Domain Name: www.vijay.com--->192.168.100.175
1.nginx Configuration
Server { a; server_name www.vijay.com; / { proxy_pass http://192.168.100.175:8080/; proxy_redirect off; Proxy_set_header Host $host; Proxy_set_header X -real-ip $remote _addr; Proxy_set_header x-forwarded-for$proxy _add_x_forwarded_for; } /Status { stub_status on; Access_log on; } }
2.web server-side log configuration (such as Tomcat)
<valve classname= Org.apache.catalina.valves.AccessLogValve Directory= " logs " = localhost_access_log suffix=" .txt " =" %h %{x-forwarded-for}i%{x-real-ip}i%{host}i %l%u%t "%r" %s%b />
3.log log:
192.168.100.175 192.168.100.169 192.168.100.169Www.vijay.com--[ One/may/ .: -: +: -+0800]"get/bg-upper.png http/1.0" 304-192.168.100.175 192.168.100.169 192.168.100.169Www.vijay.com--[ One/may/ .: -: +: -+0800]"get/bg-nav.png http/1.0" 304-192.168.100.175 192.168.100.169 192.168.100.169Www.vijay.com--[ One/may/ .: -: +: -+0800]"get/asf-logo.png http/1.0" 304-192.168.100.175 192.168.100.169 192.168.100.169Www.vijay.com--[ One/may/ .: -: +: -+0800]"get/bg-button.png http/1.0" 304-192.168.100.175 192.168.100.169 192.168.100.169Www.vijay.com--[ One/may/ .: -: +: -+0800]"get/tomcat.png http/1.0" 304-192.168.100.175 192.168.100.169 192.168.100.169Www.vijay.com--[ One/may/ .: -: +: -+0800]"get/bg-middle.png http/1.0" 304-
%h:192.168.100.175
%{x-forwarded-for}i:192.168.100.169
%{x-real-ip}i:192.168.100.169
%{host}i:www.vijay.com
Note:
In general, X-forwarded-for is used to record agent information, each through a level of agent (except anonymous proxy), the proxy server will be the source IP of the request is appended in X-forwarded-for from 4. 4.4 1.1. 1.1 2.2. 2.2 3.3. 3.3 represents the request by 1. 1.1. 1 issued, after three layers of agent, the first layer is 2. 2.2. 2, the second floor is 3. 3.3. 3, and the source of this request is IP4. 4.4
1.1. 1.1 So, if there is only one layer of proxy, the value of these two headers is the same.
Nginx Proxy Module