docker+xdebug 问题?

新手上路,请多包涵
[xdebug]
xdebug.remote_enable=1
xdebug.remote_connect_back=0
xdebug.remote_host=192.168.65.2
xdebug.remote_port = 9002
xdebug.remote_autostart = 1
xdebug.idekey="PHPSTORM"
xdebug.auto_trace=1
xdebug.remote_log=/var/log/php/xdebug.log
xdebug.remote_handler=dbgp
xdebug.remote_mode=req

这是我的php.ini的配置,其中 192.168.65.2 是phpstorm 所在ip。用的环境是 laradock 搭起来的,在 docker-composer.yml 中配置了网关 192.168.144.1

networks:
  frontend:
    driver: ${NETWORKS_DRIVER}
  backend:
    driver: ${NETWORKS_DRIVER}
    ipam:
      driver: default
      config:
        - subnet: "192.168.144.0/20"
          gateway: "192.168.144.1"

进过调试发现,/var/log/php/xdebug.log 报错

[9] Log opened at 2022-07-15 03:06:52
[9] I: Checking remote connect back address.
[9] I: Checking header 'HTTP_X_FORWARDED_FOR'.
[9] I: Checking header 'REMOTE_ADDR'.
[9] I: Remote address found, connecting to 192.168.144.1:9002.
[9] W: Creating socket for '192.168.144.1:9002', poll success, but error: Operation now in progress (29).
[9] E: Could not connect to client. :-(

根本没有走ini中的我的本机ip而是去了网关,这是怎么回事呢

阅读 1.5k
1 个回答

不要指定固定IP, 设置 xdebug.discover_client_host = true 试试.

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进