duanshang3230 2017-03-04 11:47 采纳率: 100%
浏览 71

无法在Varnish后面调试

I'm using PHP 7.1.2 with Xdebug 2.5.1 to run WordPress on my localhost dev environment. I'm using nginx to listen at 443, which forwards to Varnish on port 6081, which in turn fetches from another nginx backend listening on port 8080, which forwards PHP requests to PHP-FPM on port 9000

nginx:443 -> varnish:6081 -> nginx:8080 -> php-fpm:9000

When I try to debug using PhpStorm everything works fine: Xdebug connects and breakpoints are hit, as long as I hit the nginx backend on port 8080. However, when I go via Varnish, Xdebug fails to connect.

I looked at the question at Using Xdebug when the php application sits behind Varnish but this didn't fix my problem.

Does anyone possibly have an idea what could be wrong? I need to fix some ESI includes, but I can't even get a debug session going to inspect PHP variables.

I was wondering if Varnish is perhaps dropping some headers that are required by Xdebug to connect?

My XDebug config looks as follows:

[xdebug]
zend_extension="/usr/local/opt/php71-xdebug/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_autostart = 1
xdebug.remote_port = 9001

To try and get Xdebug working, I am just passing in vcl_recv(), and incorporated the fix from the above link I mentioned:

sub vcl_recv {
    if (req.http.x-forwarded-for) {
         set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
    } else {
         set req.http.X-Forwarded-For = client.ip;
    }

    return(pass);
}

So far, turned xdebug.remote_log on and it outputs:

Log opened at 2017-03-04 12:22:51                                                                                                                                                                               
I: Checking remote connect back address.                                                                                               
I: Checking header 'HTTP_X_FORWARDED_FOR'.                                                                                                                                                                     
I: Remote address found, connecting to 127.0.0.1, 127.0.0.1, 127.0.0.1:9001.                                                                                                                                    
W: Creating socket for '127.0.0.1, 127.0.0.1, 127.0.0.1:9001', getaddrinfo: Undefined error: 0.                                                                                                                
E: Could not connect to client. :-(                                                                                                                                                                           Log closed at 2017-03-04 12:22:52

Something is wrong with the 127.0.0.1, 127.0.0.1, 127.0.0.1:9001 address.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 NX MCD仿真与博途通讯不了啥情况
    • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
    • ¥15 gradio的web端页面格式不对的问题
    • ¥15 求大家看看Nonce如何配置
    • ¥15 Matlab怎么求解含参的二重积分?
    • ¥15 苹果手机突然连不上wifi了?
    • ¥15 cgictest.cgi文件无法访问
    • ¥20 删除和修改功能无法调用
    • ¥15 kafka topic 所有分副本数修改
    • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))