SuperAPI AI 工具集

use-cloudflare-tunnel

部署与运维

查看项目

更新于 10-16 06:45

技能介绍

用途:把本地开发服务通过 Cloudflare Tunnel 发布为公网 HTTPS 地址,供远程测试、Webhook、真机或远程浏览器验证使用,无需端口转发。

主要能力:快速隧道(try.cloudflare.com)零配置、临时 URL,无需账号、令牌或 DNS,支持 --output json 供代理使用;命名隧道为持久、需认证、可绑定自定义域名与 Zero Trust 策略;同源统一代理模式用一个端口同时代理前端与本地 API,规避混合内容与 CORS;协议自动协商(QUIC 失败回退 HTTP/2 over 7844)。

使用方式:快速隧道示例:bash scripts/quick-tunnel.sh --port 8080 --out /tmp/tunnel-url.txt;或 cloudflared tunnel --protocol auto --url http://127.0.0.1:8080 --no-autoupdate --output json,并用 setsid/nohup 后台运行。全栈场景先启动 node scripts/unified-proxy.mjs --port 8099 --static /tmp/web-dist --api-port 55721 --api-prefixes /api/,/auth/,/rest/,/functions/,再对 8099 建隧道。

必要的三步验证:Gate 1 本地源健康 curl -s -f http://127.0.0.1:<PORT>/<path> 须 200;Gate 2 全局 DNS 发布,dig @1.1.1.1 +short <subdomain> 须返回边缘 IP;Gate 3 目标客户端可达,ssh <client> "curl -s -o /dev/null -w '%{http_code}' <URL>" 须 200。

限制与注意:快速隧道子域重启后轮换,且无 Cloudflare Access 策略;UDP 7844 被封锁时需 --protocol auto 或 http2;勿删除 ~/.cloudflared;ingress 路径按 Go 正则解析。其余细节暂未提供。