I'm using PHP 7.1.2 with Xdebug 2.5.1 to run WordPress on my localhost dev environment. I'm using nginx to listen at 443, which forwards to Varnish on port 6081, which in turn fetches from another nginx backend listening on port 8080, which forwards PHP requests to PHP-FPM on port 9000
nginx:443 -> varnish:6081 -> nginx:8080 -> php-fpm:9000
When I try to debug using PhpStorm everything works fine: Xdebug connects and breakpoints are hit, as long as I hit the nginx backend on port 8080. However, when I go via Varnish, Xdebug fails to connect.
I looked at the question at Using Xdebug when the php application sits behind Varnish but this didn't fix my problem.
Does anyone possibly have an idea what could be wrong? I need to fix some ESI includes, but I can't even get a debug session going to inspect PHP variables.
I was wondering if Varnish is perhaps dropping some headers that are required by Xdebug to connect?
My XDebug config looks as follows:
[xdebug]
zend_extension="/usr/local/opt/php71-xdebug/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_autostart = 1
xdebug.remote_port = 9001
To try and get Xdebug working, I am just passing in vcl_recv()
, and incorporated the fix from the above link I mentioned:
sub vcl_recv {
if (req.http.x-forwarded-for) {
set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
return(pass);
}
So far, turned xdebug.remote_log on and it outputs:
Log opened at 2017-03-04 12:22:51
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Remote address found, connecting to 127.0.0.1, 127.0.0.1, 127.0.0.1:9001.
W: Creating socket for '127.0.0.1, 127.0.0.1, 127.0.0.1:9001', getaddrinfo: Undefined error: 0.
E: Could not connect to client. :-( Log closed at 2017-03-04 12:22:52
Something is wrong with the 127.0.0.1, 127.0.0.1, 127.0.0.1:9001
address.