基于docker的LNMP(linux nginx mysql php ^ _ ^)环境,所有这些我都在一个容器中。
目前,xdebug可以正常使用。
但是我需要输入代码herexdebug.remote_host = visitor IP
,我们的IP一直在变化。
这是一个尴尬的情况。
如果我设置xdebug.remote_connect_back = 1
来让xdebug处理IP的自动返回。
Docker的container
是在默认桥接模式下启动的,因此PHP获得的IP是桥接IP。
即:类似于172.0.0.1,无法获取真实客户端的IP地址,因此xdebug无法正确返回。
Xdebug.log日志也有记录:
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
这个问题困扰了很长时间,还是希望,请不要短时间给予指导!非常感谢
这是我的Nginx主机配置文件
server {
listen 80;
server_name test.lh.XXX.com;
access_log /var/log/nginx/access_XXX_log;
error_log /var/log/nginx/error_XXX_log;
index index.html index.htm index.php index.phtml;
client_max_body_size 100m;
set $public_root /home/xxx/www/xxx_xxx_www/public;
root $public_root;
if (!-e $request_filename) {
rewrite ^/(.*) /index.php?/$1 last;
}
location / {
try_files $uri $uri/ $uri=404;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
这是我的nginx fastcgi_param
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;