OpenClaw 在 Windows 部署启用 WebUI (via IIS)

在局域网的另一台 Windows 服务器部署 OpenClaw,发现通过客户端浏览器无法访问。主要报错有两条,一条是 Origins 的问题,一条是关于 HTTPS 安全性的问题。

origin not allowed (open the Control UI from the gateway host or allow it in gateway.controlUi.allowedOrigins)
control ui requires device identity (use HTTPS or localhost secure context)

HTTPS

本文利用 IIS 做反向代理以配置 HTTPS。你也可以用其他方案。

先下载安装 URL RewriteApplication Request Routing (ARR)。然后参考下面两篇文章,先自签一个 SSL 证书,再配置反向代理。

本文以 OpenClaw 原始端口为 18789、反代端口为 3020、运行 OpenClaw 的局域网服务器 IP 为 192.168.114.51 为例。

Origins

解决此问题,按照提示在配置文件 C:\Users\<Username>\.openclaw\openclaw.jsongateway.controlUi.allowedOrigins 中加上局域网 IP 的端口即可,新增两条,一个是 HTTP 的原始端口,一个是 HTTPS 的 TLS 端口。

"https://192.168.114.51:3020",
"http://192.168.114.51:18789",

需要注意的是,此处不支持 * 通配符,必须写明 IP 地址和端口号。

gateway 配置片段如下。

"gateway": {
  "port": 18789,
  "mode": "local",
  "bind": "lan",
  "controlUi": {
    "allowedOrigins": [
      "http://localhost:18789",
      "http://127.0.0.1:18789",

      "https://192.168.114.51:3020",
      "http://192.168.114.51:18789",
    ]
  },

配置好之后,访问 https://192.168.114.51:3020,在左侧控制概览中,找到网关访问网关令牌,填入 openclaw.json 中的 gateway.auth.token 令牌字符串,按连接按钮,根据右侧提示在服务器端授权即可。

添加新评论