Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xdebug on Mac needs nginx REMOTE_ADDR set #733

Closed
novalis111 opened this issue Apr 3, 2017 · 7 comments
Closed

xdebug on Mac needs nginx REMOTE_ADDR set #733

novalis111 opened this issue Apr 3, 2017 · 7 comments

Comments

@novalis111
Copy link

novalis111 commented Apr 3, 2017

I tried to get xdebug working on a Mac, setting my local IP (192.168.1.51) as DOCKER_HOST_IP in .env. Remote Debugging on CLI worked, but Web Debug did not.

  • xdebug IDE key = PHPSTORM
  • xdebug.remote_autostart=1 + xdebug.remote_enable=1

But xdebug wouldn't connect to the docker host. The problem is in the nginx server config, where you have to pass the IP of the host as REMOTE_ADDR:


    location ~ \.php$ {  
        try_files $uri /index.php =404;  
        fastcgi_pass php-upstream;  
        fastcgi_index index.php;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param REMOTE_ADDR "192.168.1.51";
        include fastcgi_params;
    }

I couldn't figure out how to set it from .env though, nginx only accepts IP addresses here. After setting that, the xdebug connection worked flawlessly. Would be great to add this to your PHPStorm guide. I think this is a Mac Problem, b/c the routing is done differently.

@yangliuyu
Copy link

Got xdebug works with https://github.com/DevinY/dlaravel (https://www.youtube.com/watch?v=IdMs5LjbEX0) which not modify REMOTE_ADDR. When I open the root page of the laravel project in web browser, phpstorm prompt a remote connection(xdebug) event. But for laradock, it seems no connection started from the docker.

@novalis111
Copy link
Author

novalis111 commented Apr 8, 2017

That's because nginx + php in dlaravel is in same docker container. In laradock the IP gets rewritten by nginx container, so php container doesn't get the correct remote address. Setting REMOTE_ADDR fixes that.

@yangliuyu
Copy link

@novalis111 It works now, thanks 😄 I changed the directive orders below.

include fastcgi_params;
fastcgi_param REMOTE_ADDR "192.168.1.51";

@coyl
Copy link

coyl commented May 4, 2017

#393 (comment) here is more classy solution =)

@ghost
Copy link

ghost commented Sep 8, 2017

what should i put instead of 192.168.1.51 ? the ip address where i have the IDE ?

@stale
Copy link

stale bot commented Feb 2, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale label Feb 2, 2020
@stale
Copy link

stale bot commented Feb 23, 2020

Hi again 👋 we would like to inform you that this issue has been automatically closed 🔒 because it had not recent activity during the stale period. We really really appreciate your contributions, and looking forward for more in the future 🎈.

@stale stale bot closed this as completed Feb 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants