返回顶部
c

cloudflare-agent-tunnel

>

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.1.0
安全检测
已通过
410
下载量
0
收藏
概述
安装方式
版本历史

cloudflare-agent-tunnel

# Cloudflare Agent Tunnel Give each OpenClaw agent a permanent, secure HTTPS URL via Cloudflare Tunnel — no SSL certs, no nginx, no open ports. ## How It Works ``` User → https://koda.yourdomain.com ↓ (Cloudflare edge — TLS termination here) Cloudflare Tunnel (encrypted) ↓ cloudflared process on VPS ↓ http://localhost:18789 (OpenClaw gateway) ``` - Cloudflare handles TLS — no cert management on the server - The local port never needs to be open to the internet - Each agent gets its own `cloudflared` process + systemd service --- ## ✅ Preferred Method — Named Tunnel (Permanent, Free Cloudflare Account) **Always use this method.** Gives a permanent URL tied to your domain. Requires a free Cloudflare account — takes 2 minutes to set up. ### Step 1: Install cloudflared ```bash curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null echo "deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared any main" \ | tee /etc/apt/sources.list.d/cloudflared.list apt-get update -qq && apt-get install -y cloudflared ``` ### Step 2: Authenticate — give the user this URL Run on the VPS: ```bash cloudflared tunnel login ``` This prints a Cloudflare auth URL. **Give that URL to the user** — they open it in their browser, log into their Cloudflare account, and click Authorize. This saves `/root/.cloudflared/cert.pem` on the VPS. Poll for completion: ```bash # Wait until cert.pem appears (user has authorized) until [ -f /root/.cloudflared/cert.pem ]; do sleep 3; done && echo "Authorized!" ``` ### Step 3: Create the tunnel ```bash cloudflared tunnel create openclaw-koda # Outputs a UUID — note it TUNNEL_UUID=$(cloudflared tunnel list --output json | python3 -c \ "import json,sys; t=[x for x in json.load(sys.stdin) if x['name']=='openclaw-koda']; print(t[0]['id'])") ``` ### Step 4: Write tunnel config ```bash mkdir -p /etc/cloudflared cat > /etc/cloudflared/openclaw-koda.yml << EOF tunnel: ${TUNNEL_UUID} credentials-file: /root/.cloudflared/${TUNNEL_UUID}.json ingress: - hostname: koda.yourdomain.com service: http://localhost:18789 - service: http_status:404 EOF ``` ### Step 5: Route DNS ```bash cloudflared tunnel route dns openclaw-koda koda.yourdomain.com # Automatically creates CNAME: koda.yourdomain.com → <UUID>.cfargotunnel.com ``` The domain must use **Cloudflare nameservers**. If it doesn't yet, the user transfers DNS management to Cloudflare (free, takes ~5 min). ### Step 6: Install as systemd service ```bash cat > /etc/systemd/system/cloudflared-koda.service << 'EOF' [Unit] Description=Cloudflare Tunnel — openclaw-koda After=network.target openclaw.service [Service] Type=simple User=root ExecStart=/usr/bin/cloudflared tunnel --no-autoupdate --config /etc/cloudflared/openclaw-koda.yml run Restart=always RestartSec=5 [Install] WantedBy=multi-user.target EOF systemctl daemon-reload systemctl enable cloudflared-koda systemctl start cloudflared-koda systemctl is-active cloudflared-koda ``` ### Step 7: Update OpenClaw allowedOrigins ```json "gateway": { "controlUi": { "allowedOrigins": [ "http://localhost:18789", "https://koda.yourdomain.com" ] } } ``` Then: `systemctl restart openclaw-koda` ### Step 8: Lock down the port Block direct public access — all traffic must go through the tunnel: ```bash ufw deny 18789 ufw reload ``` --- ## Quick Tunnel (Fallback Only — Temporary) > ⚠️ **Use only as a temporary fallback** when no domain is available. The URL is random and resets every time the service restarts. Switch to a named tunnel as soon as a domain is ready. ```bash # Start quick tunnel — prints a random https://*.trycloudflare.com URL cloudflared tunnel --url http://localhost:18789 --no-autoupdate # Or as a systemd service (URL logged to /var/log/cloudflared-openclaw.log) ExecStart=/usr/bin/cloudflared tunnel --no-autoupdate --url http://localhost:18789 ``` Read the assigned URL: ```bash grep -o 'https://[a-z0-9-]*\.trycloudflare\.com' /var/log/cloudflared-openclaw.log | tail -1 ``` --- ## Multi-Agent Setup (One VPS, Multiple Agents) Each agent = one OpenClaw gateway port + one named tunnel + one systemd service. ``` Port 18789 → openclaw-koda.service + cloudflared-koda.service → koda.yourdomain.com Port 18790 → openclaw-alex.service + cloudflared-alex.service → alex.yourdomain.com Port 18791 → openclaw-jordan.service + cloudflared-jordan.service → jordan.yourdomain.com ``` **Critical:** Do NOT use `cloudflared service install` for multiple agents — it only supports one tunnel and overwrites the system service. Always write individual systemd service files per agent. --- ## Custom Domains Key facts: - Domain must use **Cloudflare nameservers** (transfer at your registrar — free) - Cloudflare issues and auto-renews TLS certs - CNAME records created automatically via `cloudflared tunnel route dns` - Free Cloudflare plan: unlimited tunnels, unlimited bandwidth See `references/custom-domains.md` for a full walkthrough. --- ## Managing Tunnels ```bash # Status systemctl list-units "cloudflared-*" --no-pager # Logs journalctl -u cloudflared-koda -f # List named tunnels cloudflared tunnel list # Delete a tunnel cloudflared tunnel delete openclaw-koda systemctl disable cloudflared-koda && rm /etc/systemd/system/cloudflared-koda.service ```

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 cloudflare-agent-tunnel-1776273182 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 cloudflare-agent-tunnel-1776273182 技能

通过命令行安装

skillhub install cloudflare-agent-tunnel-1776273182

下载 Zip 包

⬇ 下载 cloudflare-agent-tunnel v1.1.0

文件大小: 7.48 KB | 发布时间: 2026-4-16 17:53

v1.1.0 最新 2026-4-16 17:53
Prefer named tunnel method — always use cloudflared login + permanent URL. Quick tunnel demoted to fallback-only with clear warning. Added polling pattern for auth URL flow.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部