Web (Gateway)
Gateway 会在 WebSocket 端口上提供一个小型的浏览器 Control UI(基于 Vite + Lit):
- 默认地址:
http://<host>:18789/ - 可选前缀:设置
gateway.controlUi.basePath(例如/openclaw)
具体功能介绍见 Control UI。 本页主要讲解绑定模式、安全配置和 Web 相关功能。
Webhook
当 hooks.enabled=true 时,Gateway 会在同一个 HTTP 服务器上暴露一个小型的 Webhook 端点。
认证和数据格式配置见 Gateway 配置 → hooks 部分。
配置(默认开启)
当资源文件存在(dist/control-ui)时,Control UI 默认启用。
你可以通过配置控制:
{
gateway: {
controlUi: { enabled: true, basePath: "/openclaw" }, // basePath 可选
},
}
Tailscale 访问
集成 Serve 模式(推荐)
让 Gateway 保持在本地回环地址,由 Tailscale Serve 代理:
{
gateway: {
bind: "loopback",
tailscale: { mode: "serve" },
},
}
然后启动 Gateway:
openclaw gateway
打开:
https://<magicdns>/(或你配置的gateway.controlUi.basePath)
Tailnet 绑定 + Token
{
gateway: {
bind: "tailnet",
controlUi: { enabled: true },
auth: { mode: "token", token: "your-token" },
},
}
然后启动 Gateway(非 loopback 绑定需要 token):
openclaw gateway
打开:
http://<tailscale-ip>:18789/(或你配置的gateway.controlUi.basePath)
公网访问(Funnel)
{
gateway: {
bind: "loopback",
tailscale: { mode: "funnel" },
auth: { mode: "password" }, // 或使用环境变量 OPENCLAW_GATEWAY_PASSWORD
},
}
安全说明
- Gateway 默认需要认证(token/password 或 Tailscale 身份头)。
- 非 loopback 绑定必须配置共享 token/password(通过
gateway.auth或环境变量)。 - 向导会默认生成 Gateway token(即使在 loopback 模式下)。
- UI 会发送
connect.params.auth.token或connect.params.auth.password。 - 使用 Serve 模式时,当
gateway.auth.allowTailscale为true时,Tailscale 身份头可以满足认证要求(无需 token/password)。设置gateway.auth.allowTailscale: false可强制要求显式凭据。详见 Tailscale 和安全。 gateway.tailscale.mode: "funnel"需要gateway.auth.mode: "password"(共享密码)。
构建 UI
Gateway 从 dist/control-ui 提供静态文件。构建命令:
pnpm ui:build # 首次运行会自动安装 UI 依赖