服务在家中,白嫖 Cloudflare 的公网 IP。。

aababe1e6c8f645020a9dc78a1d48a92.gif

Cloudflare 推出的 Argo Tunnel 本意是保护 Web 应用程序,连接服务器端口和 Cloudflare 节点,定位见下图(来自 Many services, one cloudflared[1]

7f49de353b202fe803f0aec76d8a0070.png

其工作方式类似于 frp,可以将本地服务发布到公网。只不过 frp 所需的服务器 IP 在 Argo Tunnel 中变成了 Cloudflare 提供的节点。相比运营商公网 IP,Argo Tunnel 省去了跟运营商扯皮的时间,相比于 frp 则省去了服务器的成本。

滥用开始

下文将展示如何在 Debian 10 下安装并使用 Cloudflare Argo Tunnel。

环境

  • Debian 10

准备

  • Cloudflare 账号

  • 接入了 Cloudflare 的域名

参考

  • Argo Tunnel – Setup[2]

步骤

以下指令在 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[3]

身份认证

Argo Tunnel Client 需要使用者登录 Cloudflare 账号以进行授权,执行

$ cloudflared tunnel login

在连接了显示器的机器上,执行完毕会自动打开浏览器,在浏览器内登录账号

在无头模式的机器上,执行完毕后会输出一个链接,复制链接到浏览器内登陆账号,登录后选择使用的域名,完成验证

a6482c26aa4efa0c991625e917e0f9a6.png

Cloudflared 会在 ~/.cloudlflared/ 下生成 cert.pem 证书,之后的操作都依赖于此文件

新建 Tunnel

执行

$ cloudflared tunnel create [Tunnel 名称]
95b023745d04b304f06040fe6966c241.png

每个 Tunnel 都对应一个 UUID,每新建一个 Tunnel,Cloudflared 都会在 ~/.cloudflared/ 下生成对应 UUID 的 json 文件

配置 DNS 记录

访问域名的控制面板,进入 DNS 配置页,新建 CNAME 记录,名称填写任意字符,目标填写 [tunnel 的 UUID].cfargotunnel.com

4483d0a52e105d672c5d3a78a2302704.png

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[4]

开启 Tunnel

执行

$ cloudflared tunnel --config [配置文件路径] run

如果不指定配置文件路径,cloudflared 会默认读取 ~/.cloudflared/config.yml

41d418ba0704dc7625f62be18cdf6f82.png

配置为系统服务

执行

$ cloudflared service install

cloudflared 会新建 systemd 文件,其它系统可以查看 Run as a service[5]

开启服务

$ systemctl start cloudflared.service
$ systemctl status cloudflared.service

效果

f470be25bccf8ce550228debc06c326f.png

本地 IP 访问。

745ffa9a77f8e2faee7d09fca530d611.png

通过 Argo Tunnel 访问本地网页。

引用链接

[1]

Many services, one cloudflared: https://blog.cloudflare.com/many-services-one-cloudflared/

[2]

Argo Tunnel – Setup: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup

[3]

Install cloudflared: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation

[4]

Ingress rules: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/configuration/ingress

[5]

Run as a service: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/run-tunnel/run-as-service

原文链接: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/

22ce636d20890a8af3631dfec1738753.gif

54ee168fe4ed110bd3b7a8d909b7ec21.png

你可能还喜欢

点击下方图片即可阅读

79241e52f81a798c4e4abb6a4f2e472b.png

用 Nginx 在公网上搭建加密数据通道

7bc9dbef81f1b521abb497e3ad409f54.gif

云原生是一种信仰 🤘

关注公众号

后台回复◉k8s◉获取史上最方便快捷的 Kubernetes 高可用部署工具,只需一条命令,连 ssh 都不需要!

f67b2b3d528d5e76bc29e7c41ddb114b.gif

248b8fbd7ee87884af69ccea1821323f.gif

点击 "阅读原文" 获取更好的阅读体验!

发现朋友圈变“安静”了吗?

344e54e12966ac2d910818d8edf0995c.gif

  • 4
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值