Appearance
Web 接口(Gateway)
Gateway 从与 Gateway WebSocket 相同的端口提供小型浏览器 Control UI(Vite + Lit):
- 默认:
http://<host>:18789/ - 可选前缀:设置
gateway.controlUi.basePath(如/openclaw)
功能详情见 Control UI。本页重点介绍绑定模式、安全性和面向 Web 的接口。
Webhooks
当 hooks.enabled=true 时,Gateway 也在同一 HTTP 服务器上暴露一个小型 Webhook 端点。认证和载荷说明见 Gateway 配置 → hooks。
配置(默认开启)
当资源文件存在(dist/control-ui)时,Control UI 默认启用。你可以通过配置控制:
json5
{
gateway: {
controlUi: { enabled: true, basePath: "/openclaw" }, // basePath 可选
},
}Tailscale 访问
集成 Serve(推荐)
将 Gateway 保留在回环接口,让 Tailscale Serve 代理:
json5
{
gateway: {
bind: "loopback",
tailscale: { mode: "serve" },
},
}然后启动网关:
bash
openclaw gateway打开:
https://<magicdns>/(或你配置的gateway.controlUi.basePath)
Tailnet 绑定 + Token
json5
{
gateway: {
bind: "tailnet",
controlUi: { enabled: true },
auth: { mode: "token", token: "your-token" },
},
}然后启动网关(非回环绑定需要 token):
bash
openclaw gateway打开:
http://<tailscale-ip>:18789/(或你配置的gateway.controlUi.basePath)
公共互联网(Funnel)
json5
{
gateway: {
bind: "loopback",
tailscale: { mode: "funnel" },
auth: { mode: "password" }, // 或 OPENCLAW_GATEWAY_PASSWORD
},
}安全说明
- Gateway 认证默认是必需的(token/密码或 Tailscale 身份头)。
- 非回环绑定仍然需要共享 token/密码(
gateway.auth或环境变量)。 - 向导默认生成网关 token(即使在回环上)。
- UI 发送
connect.params.auth.token或connect.params.auth.password。 - 对于非回环 Control UI 部署,需显式设置
gateway.controlUi.allowedOrigins(完整来源)。没有设置时,网关启动默认被拒绝。 gateway.controlUi.dangerouslyAllowHostHeaderOriginFallback=true启用基于 Host 头的来源回退模式,但这是危险的安全降级。- 使用 Serve 时,当
gateway.auth.allowTailscale为true时,Tailscale 身份头可满足 Control UI/WebSocket 认证(无需 token/密码)。HTTP API 端点仍需 token/密码。设置gateway.auth.allowTailscale: false要求显式凭据。详见 Tailscale 和 安全性。此无 token 流程假定网关主机是可信的。 gateway.tailscale.mode: "funnel"需要gateway.auth.mode: "password"(共享密码)。
构建 UI
Gateway 从 dist/control-ui 提供静态文件,构建方式:
bash
pnpm ui:build # 首次运行自动安装 UI 依赖