How can I use XDebug with a PHP upstream behind an nginx reverse proxy?
Here's how I got PHP Storm to connect to a dockerized php-fpm / nginx application:
Inject the remote host IP into the container. In your host, set the variable:
XDEBUG_HOST=$(ipconfig getifaddr en0)
I'm not too familiar with docker-compose. I'm using a Kubernetes manifest, but I'm sure there's a way to inject environment variables.
in xdebug.ini:
xdebug.remote_host=${XDEBUG_HOST}
Now you should be able to set up your xdebug client to listen on xdebug.remote_port
for debug connections. You'll also have to set up a debug server in PHP Storm or whatever IDE you're using that points to http://127.0.0.1:8080 (or whatever port you're port-forwarding the nginx container to).
Here's what my setup looks like. I'm using PHP Storm but I'm sure you can adapt this to other xdebug clients.
xdebug.ini:
zend_extension=xdebug.soxdebug.remote_enable=1xdebug.remote_port=10000xdebug.remote_autostart=1xdebug.idekey=www-dataxdebug.remote_host=${XDEBUG_HOST}
Reference: https://shippingdocker.com/xdebug/