Cloudflare Tunnel:没有公网IP也能暴露本地服务

概述

Cloudflare Tunnel(原Argo Tunnel)创建从你的服务器到 Cloudflare 网络的安全隧道,无需公网IP、无需开放端口。

安装

# 下载 Cloudflare Tunnel 客户端
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o /usr/local/bin/cloudflared
chmod +x /usr/local/bin/cloudflared

# 登录你的 Cloudflare 账号
cloudflared tunnel login

创建隧道

# 创建隧道
cloudflared tunnel create my-tunnel

# 配置DNS
cloudflared tunnel route dns my-tunnel my-service.你的域名.com

配置文件

创建 ~/.cloudflared/config.yml

tunnel: my-tunnel
credentials-file: /root/.cloudflared/my-tunnel.json
ingress:
  - hostname: my-service.你的域名.com
    service: http://localhost:3000
  - service: http_status:404

启动

cloudflared tunnel run my-tunnel

这篇文章对你有帮助吗?