Tailscale (Gateway 仪表板)
OpenClaw 可以为 Gateway 仪表板和 WebSocket 端口自动配置 Tailscale Serve(tailnet)或 Funnel(公共)。这使 Gateway 绑定到回环地址,而 Tailscale 提供 HTTPS、路由和(对于 Serve)身份标头。
模式
serve:通过tailscale serve仅限 Tailnet 的 Serve。网关保持在127.0.0.1。funnel:通过tailscale funnel提供公共 HTTPS。OpenClaw 需要共享密码。off:默认(无 Tailscale 自动化)。
认证
设置 gateway.auth.mode 来控制握手:
token(设置OPENCLAW_GATEWAY_TOKEN时的默认值)password(通过OPENCLAW_GATEWAY_PASSWORD或配置的共享密钥)
当 tailscale.mode = "serve" 且 gateway.auth.allowTailscale 为 true 时, 有效的 Serve 代理请求可以通过 Tailscale 身份标头 (tailscale-user-login)进行身份验证,无需提供令牌/密码。OpenClaw 通过 本地 Tailscale 守护进程(tailscale whois)解析 x-forwarded-for 地址 并将其与标头匹配来验证身份。 OpenClaw 仅在请求来自回环地址且带有 Tailscale 的 x-forwarded-for、 x-forwarded-proto 和 x-forwarded-host 标头时,才将其视为 Serve 请求。 要求明确的凭据,请设置 gateway.auth.allowTailscale: false 或 强制 gateway.auth.mode: "password"。
配置示例
仅限 Tailnet(Serve)
{
gateway: {
bind: "loopback",
tailscale: { mode: "serve" },
},
}打开:https://<magicdns>/(或您配置的 gateway.controlUi.basePath)
仅限 Tailnet(绑定到 Tailnet IP)
当您希望 Gateway 直接监听 Tailnet IP(无 Serve/Funnel)时使用此选项。
{
gateway: {
bind: "tailnet",
auth: { mode: "token", token: "your-token" },
},
}从另一个 Tailnet 设备连接:
- 控制 UI:
http://<tailscale-ip>:18789/ - WebSocket:
ws://<tailscale-ip>:18789
注意:在此模式下,回环地址(http://127.0.0.1:18789)不可用。
公共互联网(Funnel + 共享密码)
{
gateway: {
bind: "loopback",
tailscale: { mode: "funnel" },
auth: { mode: "password", password: "replace-me" },
},
}优先使用 OPENCLAW_GATEWAY_PASSWORD 而不是将密码提交到磁盘。
CLI 示例
openclaw gateway --tailscale serve
openclaw gateway --tailscale funnel --auth password注意事项
- Tailscale Serve/Funnel 需要安装
tailscaleCLI 并登录。 tailscale.mode: "funnel"拒绝启动,除非认证模式为password,以避免公共暴露。- 如果您希望 OpenClaw 在关闭时撤销
tailscale serve或tailscale funnel配置,请设置gateway.tailscale.resetOnExit。 gateway.bind: "tailnet"是直接的 Tailnet 绑定(无 HTTPS,无 Serve/Funnel)。gateway.bind: "auto"优先使用回环地址;如果只想使用 Tailnet,请使用tailnet。- Serve/Funnel 仅暴露 Gateway 控制 UI + WS。节点通过相同的 Gateway WS 端点连接,因此 Serve 可用于节点访问。
浏览器控制(远程 Gateway + 本地浏览器)
如果您在一台机器上运行 Gateway,但想在另一台机器上驱动浏览器, 请在浏览器机器上运行节点主机,并将两者保持在同一 tailnet 上。 Gateway 会将浏览器操作代理到节点;无需单独的控制服务器或 Serve URL。
避免将 Funnel 用于浏览器控制;将节点配对视为操作员访问。
Tailscale 先决条件 + 限制
- Serve 需要为您的 tailnet 启用 HTTPS;如果缺少,CLI 会提示。
- Serve 注入 Tailscale 身份标头;Funnel 不会。
- Funnel 需要 Tailscale v1.38.3+、MagicDNS、启用 HTTPS 和 funnel 节点属性。
- Funnel 仅支持通过 TLS 的
443、8443和10000端口。 - macOS 上的 Funnel 需要开源 Tailscale 应用变体。
了解更多
- Tailscale Serve 概述:https://tailscale.com/kb/1312/serve
tailscale serve命令:https://tailscale.com/kb/1242/tailscale-serve- Tailscale Funnel 概述:https://tailscale.com/kb/1223/tailscale-funnel
tailscale funnel命令:https://tailscale.com/kb/1311/tailscale-funnel