How to rebug remotely using xdebug + docker with PhpStorm

Hello everyone,

 

I managed to use xdebug with a docker stack running on my own computer : https://github.com/programgames/oro-docker-xdebug-stack
to debug web page using chrome and xdebug helper extension. Nothing really special except the fact that

xdebug.remote_host is the ip of the host on linux and docker.for.mac.localhost on macos

I actually use this config :

error_reporting = E_ALL
display_startup_errors = On
display_errors = On
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9001
xdebug.remote_autostart=1
xdebug.remote_connect_back=0
xdebug.idekey=PHPSTORM
xdebug.remote_host=docker.for.mac.localhost


But now, i need to run this stack remotely on server and still debug from my computer ( MacOs ) .
I read many tutorial about how to debug remotly but no one was enough good to explain how to configure it with Docker.
Well, my questions are :

To debug remotely what should be the xdebug.remote_host. value ? my private/public ip ? my server private/ip ? 
Do I need an ssh port fordwarding ?
Do i need to setup a dbgp proxy on server and in PhpStorm config ?
If yes , what is the config ? port / ip ?
What should be  xdebug port in this case ? 




1 comment
Comment actions Permalink

Hi there,

If it's a Docker on remote server then yes, you would need a reverse SSH tunnel (to secure your connection/by pass NAT/router issues etc).

The overall idea is:

  • Xdebug from inside the container must connect to host OS (on that remote server)
  • Then SSH tunnel is used to bring that Xdebug connection back to your local computer

Check this SO question, it should give you some ideas: https://stackoverflow.com/q/62580411/783119

 

For Xdebug:

  • host -- the IP of the host OS where Docker is running (https://stackoverflow.com/q/22944631/783119). Unless you establish SSH connection directly into inside the container.
  • port: could be any reasonable number -- it will be used by SSH. You can use the same 9000 all the way through as long as you configure it.
  • there is no real need for DBGp Proxy -- reverse SSH tunnel can do the job here.

Sadly I can give you only this general info and not "copy-paste this to have it working" instructions.

1

Please sign in to leave a comment.