Skip to content

OpenClaw Gateway 部署在 exe.dev 虚拟机后,可通过 https://<vm-name>.exe.xyz 从笔记本远程访问 Control UI。推荐使用 exe.dev 的 Shelley 代理一键安装,也可手动配置 nginx 反向代理将端口 18789 转发到 8000。远程渠道配置通过 config patch.env 文件管理密钥,设备配对需在 Gateway 运行后用 openclaw devices approve 完成。

OpenClaw exe.dev 远程网关部署与配置

目标:OpenClaw Gateway 运行在 exe.dev 虚拟机,通过 https://<vm-name>.exe.xyz 从笔记本远程控制。

本页假设 exe.dev 默认的 exeuntu 镜像。如果选择其他发行版,请相应调整软件包命令。

快速上手(Shelley 自动安装)

  1. 打开 https://exe.new/openclaw
  2. 填写认证 key/token
  3. 点击 VM 旁边的 "Agent",等待 Shelley 完成预配
  4. 打开 https://<vm-name>.exe.xyz/,输入 Gateway 令牌认证
  5. openclaw devices approve <requestId> 审批待处理的设备配对请求

前提条件

  • exe.dev 账号
  • (可选)通过 ssh exe.dev 访问 exe.dev 虚拟机的权限

Shelley 自动安装(推荐)

Shelley 是 exe.dev 的智能体,按以下提示词自动安装 OpenClaw:

Set up OpenClaw (https://docs.openclaw.ai/install) on this VM. Use the non-interactive and accept-risk flags for openclaw onboarding. Add the supplied auth or token as needed. Configure nginx to forward from the default port 18789 to the root location on the default enabled site config, making sure to enable Websocket support. Pairing is done by "openclaw devices list" and "openclaw devices approve <request id>". Make sure the dashboard shows that OpenClaw's health is OK. exe.dev handles forwarding from port 8000 to port 80/443 and HTTPS for us, so the final "reachable" should be <vm-name>.exe.xyz, without port specification.

Shelley 会处理 nginx 配置、onboarding 和设备配对,最终输出可访问的 URL。

手动安装

1) 创建虚拟机

本地执行:

bash
ssh exe.dev new

然后连接:

bash
ssh <vm-name>.exe.xyz

重要:保持此虚拟机有状态。OpenClaw 将配置文件、会话、渠道状态和 workspace 存储在 ~/.openclaw/ 下。

2) 安装依赖(在 VM 上)

bash
sudo apt-get update
sudo apt-get install -y git curl jq ca-certificates openssl

3) 安装 OpenClaw

bash
curl -fsSL https://openclaw.ai/install.sh | bash

4) 配置 nginx 代理

编辑 /etc/nginx/sites-enabled/default,覆盖原有内容:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    listen 8000;
    listen [::]:8000;

    server_name _;

    location / {
        proxy_pass http://127.0.0.1:18789;
        proxy_http_version 1.1;

        # WebSocket 支持
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        # 标准代理头——覆盖客户端提供的头链
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;

        # 长连接超时
        proxy_read_timeout 86400s;
        proxy_send_timeout 86400s;
    }
}

注意:这里使用 overwrite 模式($remote_addr 而非 $proxy_add_x_forwarded_for),防止客户端伪造 IP 链。OpenClaw 只信任来自明确配置的代理的转发信息。

5) 访问 Gateway 并配对设备

访问 https://&lt;vm-name&gt;.exe.xyz/,如果提示认证,输入 VM 上的令牌:

bash
openclaw config get gateway.auth.token

若未设置令牌,可用 openclaw doctor --generate-gateway-token 生成新的。如果使用密码认证(gateway.auth.mode 切换为 password),则使用 gateway.auth.password 或环境变量 OPENCLAW_GATEWAY_PASSWORD

查看待配对设备:

bash
openclaw devices list

批准设备:

bash
openclaw devices approve <requestId>

远程渠道配置

在远程 VM 上配置渠道时,推荐通过 .env 文件管理密钥,然后用 config patch 一次性应用。

设置环境变量

在 VM 上追加密钥到 ~/.openclaw/.env

bash
cat >> ~/.openclaw/.env <<'EOF'
SLACK_BOT_TOKEN=xoxb-...
SLACK_APP_TOKEN=xapp-...
DISCORD_BOT_TOKEN=...
OPENAI_API_KEY=sk-...
EOF

从本地创建补丁文件并推送

创建 openclaw.remote.patch.json5(示例):

json5
{
  secrets: {
    providers: {
      default: { source: "env" },
    },
  },
  channels: {
    slack: {
      enabled: true,
      mode: "socket",
      botToken: { source: "env", provider: "default", id: "SLACK_BOT_TOKEN" },
      appToken: { source: "env", provider: "default", id: "SLACK_APP_TOKEN" },
      groupPolicy: "open",
      requireMention: false,
    },
    discord: {
      enabled: true,
      token: { source: "env", provider: "default", id: "DISCORD_BOT_TOKEN" },
      dmPolicy: "disabled",
      dm: { enabled: false },
      groupPolicy: "allowlist",
    },
  },
  agents: {
    defaults: {
      model: { primary: "openai/gpt-5.5" },
      models: {
        "openai/gpt-5.5": { params: { fastMode: true } },
      },
    },
  },
}

先用 --dry-run 验证,然后正式应用:

bash
ssh <vm-name>.exe.xyz 'openclaw config patch --stdin --dry-run' < ./openclaw.remote.patch.json5
ssh <vm-name>.exe.xyz 'openclaw config patch --stdin' < ./openclaw.remote.patch.json5
ssh <vm-name>.exe.xyz 'openclaw gateway restart && openclaw health'

如需替换嵌套的 allowlist 为精确值(例如 Discord 频道 allowlist),使用 --replace-path

bash
ssh <vm-name>.exe.xyz 'openclaw config patch --stdin --replace-path "channels.discord.guilds[\"123\"].channels"' < ./discord.patch.json5

远程访问说明

exe.dev 处理了端口 8000 到 80/443 的转发和 HTTPS 证书。默认情况下,https://&lt;vm-name&gt;.exe.xyz 使用邮件认证。无需额外配置端口转发或反向代理。

更新 OpenClaw

bash
npm i -g openclaw@latest
openclaw doctor
openclaw gateway restart
openclaw health

详细信息参考 更新指南

相关文档

常见问题

为什么 Shelley 安装后无法访问 https://&lt;vm-name&gt;.exe.xyz

检查 exe.dev 控制台 VM 状态是否 running,确认 nginx 已配置并监听 8000 端口(ssh 到 VM 执行 sudo nginx -t 验证配置,systemctl status nginx 检查运行状态)。如果 Shelley 安装过程中没有提供正确的 auth token,重新运行 Shelley 或在 VM 上手动配置 gateway.auth.token 并重启 Gateway。

手动安装后,设备配对一直失败怎么办?

确保 Gateway 已启动且健康:openclaw health 应返回 "OK"。使用 openclaw devices list 查看是否有待配对的设备。若没有设备出现,检查 nginx 代理是否正确转发 WebSocket:确认 proxy_set_header Upgrade $http_upgradeproxy_set_header Connection "upgrade" 已包含,并重启 nginx(sudo systemctl restart nginx)。

远程渠道配置的 config patch --stdin 报错 "invalid JSON5"?

检查本地补丁文件语法,尤其是注释 JSON5 的 ///* */ 是否被正确解析。可用 jqjson5 工具本地验证:json5 < openclaw.remote.patch.json5。另外确保 .env 文件中密钥值未包含特殊字符(如 $),建议用单引号保护。