Install Xdebug in Lnmp environment based on Dcoker

based on the Lnmp environment of docker, I installed all the environments in one container.
currently xdebug can be used normally;
but we need xdebug.remote_host = visitor IP and our ip is constantly changing.
this situation is very embarrassing.

but if you set xdebug.remote_connect_back = 1 to let xdebug handle IP automatically and return automatically.
docker container I started it in the default bridge mode, so that the IP obtained by PHP is IP.
of the bridge, that is, similar to 172.0.0.1, the IP address of the real client cannot be obtained, resulting in xdebug not being able to return correctly.
xdebug.log log is also recorded:

Log opened at 2018-07-29 07:39:59
I: Checking remote connect back address.
I: Checking header "HTTP_X_FORWARDED_FOR".
I: Remote address found, connecting to :9001.
W: Creating socket for ":9001", getaddrinfo: No such file or directory.
E: Could not connect to client. :-(
Log closed at 2018-07-29 07:39:59

this problem has been plagued for a long time, but also hope that all kinds of gods, do not hesitate to give advice! Thank you very much

Mar.31,2021
Menu