内网穿透折腾半天(是我服务器配置比较复杂)【已解决】

charlescc

问题描述

买了官方的内网穿透功能,由于我服务器架构比较复杂,所以出现了许多问题。
首先是反向代理机器,转发到 业务机器,业务机器里面又是docker 搭到环境,php一个容器,nginx 一个容器。
最终结果就是,

2023-10-06 16:56:37 内网穿透服务端:接受内网配置下发客户端连接 Ip:172.18.0.6:50814
object(Workerman\Connection\TcpConnection)#98 (25) {
  ["onMessage"]=>
  object(Closure)#95 (1) {
    ["this"]=>
    object(plugin\nat\app\process\Server)#33 (5) {
      ["debug":protected]=>
      bool(true)
      ["apps":protected]=>
      array(1) {
        ["test.xxxxx.cc"]=>
        int(1)
      }
      ["auth":protected]=>
      NULL
      ["natClientConnections":protected]=>
      array(0) {
      }
      ["natSettingClientConnections":protected]=>
      array(1) {
      ["apps":protected]=>
      array(1) {
        ["test.xxxxx.cc"]=>
        int(1)
      }
      ["auth":protected]=>
      NULL
      ["natClientConnections":protected]=>
      array(0) {
      }
      ["natSettingClientConnections":protected]=>
      array(1) {
        [1]=>
        *RECURSION*
      }
    }
    ["parameter"]=>
    array(1) {
      ["$connection"]=>
      string(10) "<required>"
    }
  }
  ["onError"]=>
  NULL
  ["onBufferFull"]=>
  NULL
  ["onBufferDrain"]=>
  NULL
  ["protocol"]=>
  string(25) "Workerman\Protocols\Frame"
  ["transport"]=>
  string(3) "tcp"
  ["worker"]=>
  object(Workerman\Worker)#8 (30) {
    ["id"]=>
    int(0)
    ["name"]=>
    string(17) "plugin.nat.server"
    ["count"]=>
    int(1)
    ["user"]=>
    string(4) "root"
    ["group"]=>
    string(0) ""
    ["reloadable"]=>
    bool(false)
    ["reusePort"]=>
    bool(false)
    ["onWorkerStart"]=>
    object(Closure)#14 (2) {
      ["static"]=>
      array(1) {
        ["config"]=>
        array(5) {
          ["handler"]=>
          string(29) "plugin\nat\app\process\Server"
          ["listen"]=>
          string(19) "http://0.0.0.0:8001"
          ["reloadable"]=>
          bool(false)
          ["count"]=>
          int(1)
          ["constructor"]=>
          array(1) {
            ["debug"]=>
            bool(true)
          }
        }
      }
      ["parameter"]=>
      array(1) {
        ["$worker"]=>
        string(10) "<required>"
      }
    }
    ["onConnect"]=>
    NULL
    ["onMessage"]=>
    array(2) {
      [0]=>
      object(plugin\nat\app\process\Server)#33 (5) {
        ["debug":protected]=>
        bool(true)
        ["apps":protected]=>
        array(1) {
          ["test.xxxx.cc"]=>
          int(1)
        }
        ["auth":protected]=>
        NULL
        ["natClientConnections":protected]=>
        array(0) {
        }
        ["natSettingClientConnections":protected]=>
        array(1) {
          [1]=>
          *RECURSION*
        }
      }
      [1]=>
      string(9) "onMessage"
    }
    ["onClose"]=>
    NULL
    ["onError"]=>
    NULL
    ["onBufferFull"]=>
    NULL
    ["onBufferDrain"]=>
    NULL
    ["onWorkerStop"]=>
    NULL
    ["onWorkerReload"]=>
    NULL
    ["onWorkerExit"]=>
    NULL
    ["transport"]=>
    string(3) "tcp"
    ["connections"]=>
    array(1) {
      [1]=>
      *RECURSION*
    }
    ["protocol"]=>
    string(24) "Workerman\Protocols\Http"
  ["id"]=>
  int(1)
  ["_id":protected]=>
  int(1)
  ["maxSendBufferSize"]=>
  int(1048576)
  ["context"]=>
  object(stdClass)#92 (0) {
  }
  ["maxPackageSize"]=>
  int(10485760)
  ["_socket":protected]=>
  resource(294) of type (stream)
  ["_sendBuffer":protected]=>
  string(0) ""
  ["_recvBuffer":protected]=>
  string(0) ""
  ["_currentPackageLength":protected]=>
  int(0)
  ["_status":protected]=>
  int(2)
  ["_remoteAddress":protected]=>
  string(16) "172.18.0.6:50814"
  ["_isPaused":protected]=>
  bool(false)
  ["_sslHandshakeCompleted":protected]=>
  bool(false)
  ["__request"]=>
  object(Workerman\Protocols\Http\Request)#94 (6) {
    ["connection"]=>
    NULL
    ["session"]=>
    NULL
    ["properties"]=>
    array(0) {
    }
    ["_buffer":protected]=>
    string(230) "OPTIONS / HTTP/1.1
X-Real-IP: xxxxxx //vpn的ip地址
Host: xxxx.cc
X-Forwarded-Proto: http
X-Forwarded-For: xxxxxx, 172.18.0.1
Nat-host: xxxx.cc:9001
Nat-token: 6f69366018f0ed266e18d60957a87852
nat-setting-client: yes

"
    ["_data":protected]=>
    array(4) {
      ["headers"]=>
      array(7) {
        ["x-real-ip"]=>
        string(13) "xxxx" //vpn的ip地址
        ["host"]=>
        string(9) "xxxx.cc"
        ["x-forwarded-proto"]=>
        string(4) "http"
        ["x-forwarded-for"]=>
        string(25) "xxxx, 172.18.0.1"
        ["nat-host"]=>
        string(14) "xxxx.cc:9001"
        ["nat-token"]=>
        string(32) "6f69366018f0ed266e18d60957a87852"
        ["nat-setting-client"]=>
        string(3) "yes"
      }
      ["head"]=>
      string(226) "OPTIONS / HTTP/1.1
X-Real-IP: xxxxxx //vpn的ip地址
Host: xxxx.cc
X-Forwarded-Proto: http
X-Forwarded-For: xxxx, 172.18.0.1 //vpn的ip地址
Nat-host: xxxx.cc:9001
Nat-token: 6f69366018f0ed266e18d60957a87852
nat-setting-client: yes"
      ["method"]=>
      string(7) "OPTIONS"
      ["uri"]=>
      string(1) "/"
    }
    ["_isSafe":protected]=>
    bool(true)
  }
  ["userId"]=>
  int(1)
}

这个是下发配置,send 之前的$connection 对象。

  $connection->send(json_encode(['type' => 'setting', 'setting' => $items], JSON_UNESCAPED_UNICODE));
                ;

可我本地的nat-client 收不到下发的消息。
实在是折腾太久, 请各位大佬给点思路,怎调试

解决方案

泛解析没生效。折腾半天,哎。其他配置没问题。

813 1 0
1个回答

charlescc

初步觉得 是 $connection握手的连接信息,里面的ip端口,是容器内网。所以我客户端收不到

  • 暂无评论
年代过于久远,无法发表回答
×
🔝