Use tcpdump packet capture utility to isolate the nginx under linux get real examples of client IP

A, nginx back-end server load API can always get nginx proxy server IP in obtaining the client IP, the investigation nginx configuration is as follows

upstream sms-resp {
         server 192.168.5.216:8501;
         server 192.168.5.217:8501;
    }

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            #root   html;
            #index  index.html index.htm;
            proxy_pass  http://sms-resp;
            proxy_set_header host $host;
            proxy_set_header X-real-ip $remote_addr;
            proxy_set_header X-forwarded-for $proxy_add_x_forwarded_for;
        }

nginx configuration items have been configured convert real client IP parameter settings, then you need to see if capture is truly converted client IP.

Second, install tcpdump packet capture tool

On nginx API server and back-end are mounted tcpdump

[root@push-5-216 ~]# yum install -y tcpdump

Third, the use tcpdump packet capture

I call on 172.28.146.109 nginx proxy 172.28.5.215 browser's HTTP interface, nginx distribute requests to the 192.168.5.216, here nginx and backend API is to take the 192.168 network segment.

First grab from 172.28.146.109 to 172.28.5.215,80 port TCP packets

 

Guess you like

Origin www.cnblogs.com/sky-cheng/p/11058221.html