Nginx + php-fpm: Bad gateway only when xdebug server is running

Problem

When xdebug server is running from IntelliJ IDEA, I get 502 Bad Gateway from nginx when I try loading my site to trigger breakpoints.

If I stop the xdebug server, the site works as intended.

  • How to config my nginx to a running container with rails using raspian?
  • Is there any definitive guide on how to pass all the arguments to Docker containers while starting a container through kubernetes?
  • Docker compose can not create container for postgresql and redis
  • What does set -e and exec “$@” do for docker entypoint scripts?
  • Docker complains about invalid certificate after update to v1.7.0
  • Read-only file system error when loading docker image
  • So, I’m not able to run the debugger, but it did work previously (!). Not able to pinpoint why it suddenly stopped working.

    Setup

    A short explanation of the setup (let me know if I need to expand on this).

    My php app is running in a docker container, and it is linked to nginx running in a different container using volumes_fromin the docker compose config.

    After starting the app, I can verify using phpinfo(); the xdebug module is loaded.

    My xdebug.ini has the following content:

    zend_extension=xdebug.so
    xdebug.remote_enable=1
    xdebug.remote_host=10.0.2.2
    xdebug.remote_connect_back=0
    xdebug.remote_port=5555
    xdebug.idekey=complex
    xdebug.remote_handler=dbgp
    xdebug.remote_log=/var/log/xdebug.log
    xdebug.remote_autostart=1
    

    I got the ip address for remote_host (where the xdebug server is running) by these steps:

    docker-machine ssh default
    route -n | awk '/UG[ \t]/{print $2}' <-- Returns 10.0.2.2
    

    To verify I could reach the debugging server from within my php container, I did the following steps

    docker exec -it randomhash bash
    nc -z -v 10.0.2.2 5555
    

    Giving the following output depending on xdebug server running or not:

    • Running: Connection to 10.0.2.2 5555 port [tcp/*] succeeded!
    • Not running: nc: connect to 10.0.2.2 port 5555 (tcp) failed: Connection refused

    So IntelliJ IDEA is surely set up to receive connections on 5555. I also did the appropriate path mapping between my source file paths and the remote path (when setting up the PHP Remote Debugging server from within IDEA).

    Any ideas? Kind of lost on this one as I don’t have much experience with any of these technologies 😀

  • docker-compose pull results in x509: certificate signed by unknown authority
  • Docker swarm on physical machines without docker-machine
  • How create MongoDB cluster on Kubernetes?
  • Git clone not working with npm
  • Apache httpcomponent returns java.net.UnknownHostException: Name or service not known
  • Docker. Make volume on postgresql container
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.