Cloudflare Argo Tunnel - 公网 IP 的新解决方案
source link: https://azhuge233.com/cloudflare-argo-tunnel-%e5%85%ac%e7%bd%91-ip-%e7%9a%84%e6%96%b0%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Cloudflare 推出的 Argo Tunnel 本意是保护 Web 应用程序,连接服务器端口和 Cloudflare 节点,定位见下图(来自 Many services, one cloudflared)
其工作方式类似于 frp,可以将本地服务发布到公网。只不过 frp 所需的服务器 IP 在 Argo Tunnel 中变成了 Cloudflare 提供的节点。相比运营商公网 IP,Argo Tunnel 省去了跟运营商扯皮的时间,相比于 frp 则省去了服务器的成本
滥用开始
下文将展示如何在 Debian 10 下安装并使用 Cloudflare Argo Tunnel
- Debian 10
- Cloudflare 账号
- 接入了 Cloudflare 的域名
以下指令在 root 用户下执行,非 root 用户酌情添加 sudo
安装 Argo Tunnel Client
Argo Tunnel Client 支持 Windows、macOS 和 Linux
wget -q https://bin.equinox.io/c/VdrWdbjqyF/cloudflared-stable-linux-amd64.deb dpkg -i cloudflared-stable-linux-amd64.deb
其他操作系统安装指令查看 Install cloudflared
Argo Tunnel Client 需要使用者登录 Cloudflare 账号以进行授权,执行
cloudflared tunnel login
在连接了显示器的机器上,执行完毕会自动打开浏览器,在浏览器内登录账号
在无头模式的机器上,执行完毕后会输出一个链接,复制链接到浏览器内登陆账号,登录后选择使用的域名,完成验证
Cloudflared 会在 ~/.cloudlflared/ 下生成 cert.pem 证书,之后的操作都依赖于此文件
新建 Tunnel
cloudflared tunnel create [Tunnel 名称]
每个 Tunnel 都对应一个 UUID,每新建一个 Tunnel,Cloudflared 都会在 ~/.cloudflared/ 下生成对应 UUID 的 json 文件
配置 DNS 记录
访问域名的控制面板,进入 DNS 配置页,新建 CNAME 记录,名称填写任意字符,目标填写 [tunnel 的 UUID].cfargotunnel.com
Argo Tunnel 的一个 UUID 只会与同一账户下的一个 DNS 记录绑定
新建配置文件
新建 YAML 配置文件,写入以下内容
tunnel: [tunnel 的名称或 UUID] credentials-file: /root/.cloudflared/[tunnel 的 UUID].json ingress: - hostname: [CNAME 记录名称].[接入 CLoudflare 的域名] service: http://localhost:80 - service: http_status:404
配置文件使用 Ingress 规则,如果想配置 SSH、TCP 等其他协议,可以查看 Ingress rules
开启 Tunnel
cloudflared tunnel --config [配置文件路径] run
如果不指定配置文件路径,cloudflared 会默认读取 ~/.cloudflared/config.yml
配置为系统服务
cloudflared service install
cloudflared 会新建 systemd 文件,其它系统可以查看 Run as a service
systemctl start cloudflared.service systemctl status cloudflared.service
本地 IP 访问
通过 Argo Tunnel 访问本地网页
相关
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK