國際草包
國際草包

強制 Cloudflared tunnel 使用 http2, 解決掉線問題

2023 年 3 月 1 日附加:
Cloudflare LAX 的數據中心基本被牆的差不多了, Tunnel 最近越來越不好用, 剛剛關掉代理試了一下, 根本連不上了.

2023 年 6 月 12 日附加:
我現在已經切換到 frp 和 cloudflare argo tunnel 共存的模式了,正常情況流量走 frp, cloudflare 只用於翻牆回家或者 frp 伺服器被牆的時候使用,作為一種後備手段。

最近 cloudflared argo tunnel 很不穩定.

我一開始根本沒有意識到 tunnel 不穩定, 直到我跑了一個依賴 cloudflare tunnel 內網穿透的 api server, 才發現 api 的可用性還不到一半的時間, 我得每隔幾個小時手動重啟一下 cloudflared 的容器.

一開始我認為這是因為 cloudflared 的流量被代理了, 所以就去 openclash 設置了不代理流量, 給容器的源 ip 和目標域名都加了規則. 但是設置完之後不見好居然還更嚴重了. 我就開始思考難道是 cloudflare 被牆了? 防火牆敢牆 cloudflare?

我又拿出日誌看了一眼, 日誌大概長這個樣子:

2022-04-08T04:36:40Z INF Version 2022.4.0
2022-04-08T04:36:40Z INF GOOS: linux, GOVersion: go1.17.5, GoArch: amd64
2022-04-08T04:36:40Z INF Settings: map[no-autoupdate:true token:*****]
2022-04-08T04:36:40Z INF Generated Connector ID: d4bc3f69-ce1c-451a-af34-b688d50015f2
2022-04-08T04:36:40Z INF Will be fetching remotely managed configuration from Cloudflare API. Defaulting to protocol: quic
2022-04-08T04:36:40Z INF Initial protocol quic
2022-04-08T04:36:40Z INF Starting metrics server on 127.0.0.1:33206/metrics
2022-04-08T04:36:45Z ERR Failed to create new quic connection error="failed to dial to edge: timeout: no recent network activity" connIndex=0
2022-04-08T04:36:45Z ERR Serve tunnel error error="failed to dial to edge: timeout: no recent network activity" connIndex=0
...
2022-04-08T04:37:57Z INF Tunnel server stopped
2022-04-08T04:37:57Z INF Metrics server stopped
2022-04-08T04:37:57Z ERR Initiating shutdown error="failed to dial to edge: timeout: no recent network activity"
failed to dial to edge: timeout: no recent network activity

會不會是 QUIC 的問題?

要知道我用 cloudflared tunnel 的初衷是要混淆我的流量, 讓防火牆區分不出我的網站, 現在你 QUIC 防火牆一眼就能看出來, 這還玩個球.

解決方案

解決方案也非常簡單, 加一個命令行參數就好了

cloudflared tunnel run --protocol http2 

但是 cloudflared tunnel --help 和網站官方的文檔里都沒有寫, 我還是在 Github Issue 上看到的. 這就很迷惑. 為什麼 cloudflare 要這麼做?

https://recover.justin.education/wp-content/uploads/2023/05/2023050707170871.png
Cloudflare 開發者的解釋

謝謝你, 我確實感覺到了 pain.

參考資料

  • https://github.com/cloudflare/cloudflared/issues/617

發表回復

textsms
account_circle
email

國際草包

強制 Cloudflared tunnel 使用 http2, 解決掉線問題
2023 年 3 月 1 日附加:Cloudflare LAX 的數據中心基本被牆的差不多了, Tunnel 最近越來越不好用, 剛剛關掉代理試了一下, 根本連不上了.2023 年 6 月 12 日附加:我現在已經切換到 frp …
掃描二維碼繼續閱讀
2023-02-03