How to obtain clientIp, and host Ip in lnmp environment under Docker.

first I install the lnmp environment using a container in docker,docker under Mac. When the user accesses, when the project gets the visitor Ip, the ip, bridged by the docker such as 172.0.0.1 will never get the client ip. Google has been unable to solve the problem for a long time. Solve
and also want to go to the ip of the host. Thank you

here is the NGINX configuration


listen 80;
server_name www.nihao.test;

location / {
proxy_pass http://www.nihao.test;
                    proxy_set_header    Host             $host:$server_port;-sharp
                    proxy_set_header    X-Real-IP        $remote_addr;
                    proxy_set_header    X-Forwarded-For  $proxy_add_x_forwarded_for;
                    proxy_set_header    HTTP_X_FORWARDED_FOR $remote_addr;-sharp
                    proxy_set_header    X-Forwarded-Proto $scheme;
                    proxy_redirect      default;

    try_files $uri $uri/ $uri=404;
}
Jun.17,2021

I have the same problem. It seems impossible to configure Nginx directly. The problem of 2015 to 2018 seems to exist all the time.

< H2 > related problems found through search < / H2 >

Document how to get real remote client ip for service running in container

nginx gets the client IP implementation according to the configuration, but cannot get the real IP

network_mode-docker network connection

nginx cannot get to client IP

< hr >

= Updated 15:17:52, September 15, 2018 =

MAC- can only get the IP. of the container But you can get the real IP. of the client on Linux. questions

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b365c9-2bfff.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b365c9-2bfff.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?