nginx X-Forwarded-For

nginx :


X-Forwarded-For

 location ^~ /bbb 
 {
proxy_pass http://backend2/;
 proxy_connect_timeout 300;
 proxy_send_timeout 300;
 proxy_read_timeout 300;
  proxy_set_header   Host             $host;
 proxy_set_header   X-Real-IP        $remote_addr;       
 proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
 }
 
 
 
 
# http conf
http {
    #include     http/common.conf;
    #include     http/cache.conf;
    #include     http/resty.conf;
    #include     http/mime.types;

    include     http/*.conf;

    include     http/servers/*.conf;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
  
    access_log  logs/access.log  main;  
	
	
192.168.137.2 - - [04/Apr/2020:01:50:09 +0800] "GET // HTTP/1.0" 200 334 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36" "192.168.137.1"
192.168.137.2 - - [04/Apr/2020:01:50:13 +0800] "GET // HTTP/1.0" 200 334 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36" "192.168.137.1"
原文地址:https://www.cnblogs.com/hzcya1995/p/13348417.html