View Issue Details

IDProjectCategoryView StatusLast Update
0000598XdebugStep Debuggingpublic2020-03-12 17:19
Reportersarnowski Assigned Toderick  
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionfixed 
Product Version2.2dev 
Target Version2.2.2Fixed in Version2.2.2 
Summary0000598: Use HTTP_X_FORWARDED_FOR to determine remote debugger
Description

Use HTTP_X_FORWARDED_FOR in addition to REMOTE_ADDR to determine the remote debugger. With the following patch, xdebug can handle debuggers even if the webserver runs behind a loadbalancer/proxy.

Additional Information

~/xdebug # svn diff
Index: xdebug_stack.c

--- xdebug_stack.c (revision 3323)
+++ xdebug_stack.c (working copy)
@@ -417,7 +417,10 @@
if (!XG(remote_enabled) && XG(remote_enable) && (XG(remote_mode) == XDEBUG_JIT)) {
if (XG(remote_connect_back)) {
zval **remote_addr = NULL;

  • zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "REMOTE_ADDR", 12, (void**)&remote_addr);
  • zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_X_FORWARDED_FOR", 21, (void**)&remote_addr);
  • if (!remote_addr) {
  • zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "REMOTE_ADDR", 12, (void**)&remote_addr);
  • }
    XG(context).socket = xdebug_create_socket(Z_STRVAL_PP(remote_addr), XG(remote_port));
    } else {
    XG(context).socket = xdebug_create_socket(XG(remote_host), XG(remote_port));
    Index: xdebug.c

    --- xdebug.c (revision 3323)
    +++ xdebug.c (working copy)
    @@ -1158,7 +1158,10 @@
    / Initialize debugging session /
    if (XG(remote_connect_back)) {
    zval **remote_addr = NULL;

  • zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "REMOTE_ADDR", 12, (void**)&remote_addr);
  • zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_X_FORWARDED_FOR", 21, (void**)&remote_addr);
  • if (!remote_addr) {
  • zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "REMOTE_ADDR", 12, (void**)&remote_addr);
  • }
    if (remote_addr) {
    XG(context).socket = xdebug_create_socket(Z_STRVAL_PP(remote_addr), XG(remote_port));
    } else {
TagsNo tags attached.
Operating System
PHP Version5.2.10

Activities

darrenoh

2012-09-06 17:46

reporter   ~0002340

I just ran into this problem. I would really appreciate this feature.

darrenoh

2012-09-06 19:18

reporter   ~0002341

I see that this feature has already been added.

darrenoh

2012-09-06 20:14

reporter   ~0002342

Duplicate of 0000660. I have no explanation for why I’m experiencing this problem in version 2.2.1.

darrenoh

2012-09-06 23:00

reporter   ~0002343

This is a bug. Xdebug is checking for X_HTTP_FORWARDED_FOR instead of HTTP_X_FORWARDED_FOR.

darrenoh

2012-09-06 23:34

reporter   ~0002344

I have submitted a pull request: https://github.com/derickr/xdebug/pull/30

derick

2012-09-07 10:03

administrator   ~0002345

Fixed on github, thanks for the patch! I won't be releasing Xdebug 2.2.2 soon, but I will see if I can compile you some dev binaries.

Issue History

Date Modified Username Field Change
2010-07-23 14:15 sarnowski New Issue
2010-07-23 14:15 sarnowski PHP Version => 5.2.10
2010-07-23 14:15 sarnowski Xdebug Version => 2.2.0-dev
2012-09-06 17:46 darrenoh Note Added: 0002340
2012-09-06 19:18 darrenoh Note Added: 0002341
2012-09-06 20:14 darrenoh Note Added: 0002342
2012-09-06 23:00 darrenoh Note Added: 0002343
2012-09-06 23:34 darrenoh Note Added: 0002344
2012-09-07 10:02 derick Fixed in Version => 2.2.2
2012-09-07 10:02 derick Target Version => 2.2.2
2012-09-07 10:03 derick Note Added: 0002345
2012-09-07 10:03 derick Status new => closed
2012-09-07 10:03 derick Assigned To => derick
2012-09-07 10:03 derick Resolution open => fixed
2020-03-12 16:55 derick Severity tweak => feature
2020-03-12 17:19 derick Category Feature/Change request => Step Debugging