国际草包
国际草包

强制 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