買了官方的內(nèi)網(wǎng)穿透功能,由于我服務(wù)器架構(gòu)比較復(fù)雜,所以出現(xiàn)了許多問題。
首先是反向代理機器,轉(zhuǎn)發(fā)到 業(yè)務(wù)機器,業(yè)務(wù)機器里面又是docker 搭到環(huán)境,php一個容器,nginx 一個容器。
最終結(jié)果就是,
2023-10-06 16:56:37 內(nèi)網(wǎng)穿透服務(wù)端:接受內(nèi)網(wǎng)配置下發(fā)客戶端連接 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)
}
這個是下發(fā)配置,send 之前的$connection 對象。
$connection->send(json_encode(['type' => 'setting', 'setting' => $items], JSON_UNESCAPED_UNICODE));
;
可我本地的nat-client 收不到下發(fā)的消息。
實在是折騰太久, 請各位大佬給點思路,怎調(diào)試
泛解析沒生效。折騰半天,哎。其他配置沒問題。