Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xdebug: connection from any host

Tags:

php

xdebug

I'm using Xdebug on a virtual machine (Ubuntu guest). I'm using Vagrant to manage these VM and I'm configuring a "pattern" OS to clone it for web develop. The problem is that I want to configure this ubuntu guest to accept connection to xdebug from any host (xdebug is obviously in the guest os).

These instructions don't work:

zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_connect_back=1
xdebug.remote_port=9000

The only way seems to add a line with:

xdebug.remote_host=sdurzu

"sdurzu" is the hostname of the host, but I want to create an "universal" configuration for xdebug, not based on host name or IP.

Is there a way to use a wild card (*) or something like this?

like image 880
sergiod Avatar asked Feb 04 '13 16:02

sergiod


People also ask

How does Xdebug remote work?

When Xdebug is running, it will call back to your IDE (like PhpStorm or VS Code) from the server where it's running. Your IDE will sit and listen for that connection on a specific port (typically port 9000 or 9003).

What is Xdebug client port?

Port 9003 is the default for both Xdebug and the Command Line Debug Client. As many clients use this port number, it is best to leave this setting unchanged.

How do I know if Xdebug is working?

Verify that Xdebug is properly running by checking again with phpinfo() or php -v as explained above. Note that 9003 is the default port. If this port is used by another service on your system, change it to an unused port. After adding these settings, restart your webserver again.


1 Answers

According to the Xdebug settings documentation, remote_host is ignored if you have remote_connect_back enabled.

xdebug.remote_connect_back
Type: boolean, Default value: 0, Introduced in Xdebug >= 2.1

If enabled, the xdebug.remote_host setting is ignored and Xdebug will try to connect to the client that made the HTTP request. It checks the $_SERVER['HTTP_X_FORWARDED_FOR'] and $_SERVER['REMOTE_ADDR'] variables to find out which IP address to use.
[...]

Also, remote_connect_back should allow any device to connect to Xdebug that has access to your web server.

like image 129
docksteaderluke Avatar answered Nov 15 '22 22:11

docksteaderluke