我刚把我的这个网站迁移到我的红米Note3“服务器”上,使用Argo Tunnel作为内网穿透。网上有很多文章,我都看了看,但是有些问题依然无法解决,最后在cloudflared在Github的Issue中找到了一些答案
常规
安装
此处演示,使用的是Linux ARM64版cloudflared,其它平台大同小异
Release 2022.1.2 · cloudflare/cloudflared · GitHub
下载后将二进制文件使用mv重命名为cloudflared,以减少后期使用是敲键盘的次数(
然后就没有然后了
登录
1 | ./cloudflared tunnel login |
运行 cloudflared tunnel login,并在浏览器中选择一个域名来授权。
你的家目录中会出现 ~/.cloudflared/cert.pem。在我们创建隧道和设置 DNS 解析的时候,我们会用到这个文件。
创建隧道
1 | ./<span style="background-color: inherit; font-size: inherit;">cloudflared tunnel create <隧道名称></span> |
运行 cloudflared tunnel create [名字]
,创建一个隧道。这条命令需要之前的 cert.pem
用来验证身份。
你的家目录中会出现 ~/.cloudflared/[一长串UUID].json
,里面保存这运行这条隧道所需要的授权信息。
配置路由
创建了隧道之后,我们还需要让它可以被访问。Cloudflare 支持将其部署到负载均衡器后端,或者通过 DNS 直接访问。这里只介绍后者的使用方法。
1 | ./cloudflared tunnel route dns [名字或者 UUID] [想要绑定到的域名或其二级域名] |
你会发现这个域名被设置了一个指向 [UUID].cfargotunnel.com 的 CNAME 记录,并且通过 Cloudflare 进行代理。
设置配置文件
在.cloudflare目录中创建一个config.yml,内容如下
1 2 3 4 5 6 7 8 9 | tunnel: <你的隧道名称> credentials-file: /root/.cloudflared/<隧道UUID>.json(这里看情况,可以自己修改json路径) ingress: - hostname: <域名> service: https://127.0.0.1<此处自己视情况修改> - hostname: <域名> service: https://127.0.0.1<此处自己视情况需改> - service: http_status:404 |
运行
运行Cloudflare (默认会使用/root/.cloudflared/config.yml配置文件)
1 | ./cloudflared tunnel run |
我不太会折腾,所以为了关闭控制台后cloudflared保持运行,我使用screen
解决问题
修复无法创建链接
提示信息
1 | ERR Unable to establish connection with Cloudflare edge error="TLS handshake with edge error: EOF" connIndex=0 |
参考:开启全局透明代理后,cloudflared(argo tunnel)无法使用 - V2rayA/V2rayA (issueexplorer.com)
解决办法:不使用任何代理
修复SSL问题
提示的内容
1 | ERR error="Unable to reach the origin service. The service may be down or it may not be responding to traffic from cloudflared: x509: cannot validate certificate for 127.0.0.1 because it doesn't contain any IP SANs" |
解决方法
在配置文件中加入以下内容
1 2 | originRequest: noTLSVerify: true |
Named tunnels wont accept no-tls-verify · Issue #277 · cloudflare/cloudflared · GitHub
发表回复