I have a PHP server running through PHP-FPM which is served with fastcgi through nginx on port 7000
. This application has been dockerized and is running as a running container, e.g. my_api.
The my_api
docker container can be connected to directly via port 7000
(for sanity checking) as well as through another container which acts as an nginx reverse proxy that uses upstreams to expose the my_api
application (and others) on ports 80
and 443
(port 80
redirects to SSL) through proxy_pass
directives under the appropriate locations.
If I start an XDebug session using dbgp on port 9000
directly against a file served from http://localhost:7000 I can see the debugging session established correctly and I can debug.
However, if I attempt to start the XDebug session against the URL served by the nginx reverse proxy, e.g. https://localhost/my-api, the debug session does not appear to start or at least it doesn't create the connection properly (no breakpoints are hit in my IDE, etc.).
How can I establish an XDebug session for requests made through the nginx reverse proxy?
For purposes of this question, below is a (relevant) sample of my docker-compose.yml
configuration and xdebug.ini
:
docker-compose.yml:
version: "2"
services:
api:
build: <path_to_dockerfile>
ports:
- 7000:7000
#- 9000:9000 # may be uncommented for direct debugging access
nginx_proxy:
build: <path_to_dockerfile>
links:
...
- api:api
ports:
- 80:80
- 443:443
xdebug.ini
zend_extension=xdebug.so
xdebug.remote_enable=true
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_autostart=0
NB: I've tried a couple of different configurations to try and get this working, including launching a Docker container running a dbgpproxy but nothing seems to allow me to debug requests which pass through the reverse proxy. It is very possible though that the configuration I was using for these attempts was just wrong.
I have a few theories on what my problems may be, among them the suspicion that it is the reverse proxy's IP address that is being communicated to XDebug via the remote_connect_back
configuration property.
Any help or insight into how to properly configure XDebug to work with requests that are made to a server via nginx proxy passes to an upstream server would be greatly appreciated!
I can provide further details if it would be helpful!
xdebug.remote_connect_back=1
-- make it =0
and use proper host/IP inxdebug.remote_host