什么是 Remote Gateway
OpenClaw 的 Remote Gateway 功能允许你在不同网络环境中运行 Gateway 节点,并将它们连接到中心控制平面。这对于多地域部署、跨网络访问和高可用架构非常有用。
架构概述
Remote Gateway 架构包含两个角色:
- 主 Gateway(Primary):中心节点,管理配置和路由
- 远程 Gateway(Remote):部署在其他网络中的节点
远程节点通过安全连接与主节点通信,主节点负责统一配置分发和健康监控。
配置主 Gateway
在主 Gateway 上启用远程连接:
{
"gateway": {
"remote": {
"enabled": true,
"listenPort": 3100,
"authToken": "{{REMOTE_AUTH_TOKEN}}",
"tls": {
"enabled": true,
"cert": "/path/to/cert.pem",
"key": "/path/to/key.pem"
}
}
}
}
生成认证 Token:
openclaw secrets set REMOTE_AUTH_TOKEN "$(openssl rand -hex 32)"
配置远程 Gateway
在远程节点上安装 OpenClaw 后,配置连接到主节点:
{
"gateway": {
"mode": "remote",
"primaryUrl": "https://primary-gateway.example.com:3100",
"authToken": "{{REMOTE_AUTH_TOKEN}}",
"nodeName": "remote-us-east",
"syncInterval": 30000
}
}
启动远程节点:
openclaw start --mode remote
多地域部署示例
一个典型的多地域部署架构:
主 Gateway (东京)
├── 远程 Gateway (北京) ← 服务中国用户
├── 远程 Gateway (法兰克福) ← 服务欧洲用户
└── 远程 Gateway (纽约) ← 服务美国用户
每个远程节点连接不同的频道和使用不同的模型供应商:
{
"gateway": {
"mode": "remote",
"primaryUrl": "https://primary.example.com:3100",
"nodeName": "remote-beijing",
"localProviders": {
"qianfan": {
"type": "openai",
"baseUrl": "https://qianfan.baidubce.com/v2",
"apiKey": "{{QIANFAN_API_KEY}}"
}
},
"localChannels": {
"wechat-cn": {
"model": "ernie-4.0",
"provider": "qianfan"
}
}
}
}
配置同步
远程节点会定期从主节点同步配置:
{
"gateway": {
"sync": {
"interval": 30000,
"syncModels": true,
"syncSkills": true,
"syncSecurity": true,
"overrideLocal": false
}
}
}
overrideLocal: false 表示本地配置优先级高于同步的配置,适合需要本地定制的场景。
健康监控
主节点会监控所有远程节点的健康状态:
# 查看所有节点状态
openclaw gateway status --all
输出:
Gateway Nodes:
primary (tokyo) ✓ healthy latency: 0ms
remote-beijing ✓ healthy latency: 45ms
remote-frankfurt ✓ healthy latency: 120ms
remote-newyork ✗ offline last seen: 5m ago
安全通信
远程连接应始终使用 TLS 加密。使用 Let's Encrypt 获取证书:
certbot certonly --standalone -d gateway.example.com
配置 TLS:
{
"gateway": {
"remote": {
"tls": {
"enabled": true,
"cert": "/etc/letsencrypt/live/gateway.example.com/fullchain.pem",
"key": "/etc/letsencrypt/live/gateway.example.com/privkey.pem"
}
}
}
}
故障转移
当远程节点离线时,可以配置自动故障转移:
{
"gateway": {
"failover": {
"enabled": true,
"healthCheckInterval": 10000,
"unhealthyThreshold": 3,
"fallbackNode": "primary"
}
}
}
带宽优化
远程节点与主节点之间的通信可以优化:
{
"gateway": {
"sync": {
"compression": true,
"deltaSync": true,
"batchSize": 100
}
}
}
compression:启用数据压缩deltaSync:只同步变更部分batchSize:批量同步消息数
日志集中收集
配置远程节点将日志发送到主节点:
{
"logging": {
"remote": {
"enabled": true,
"endpoint": "https://primary.example.com:3100/logs",
"batchInterval": 5000
}
}
}
总结
Remote Gateway 是 OpenClaw 实现全球化部署的关键功能。通过在不同地域部署远程节点,可以为各地用户提供低延迟的服务,同时通过中心化的主节点实现统一配置和监控管理。