注册地址: https://dashboard.ngrok.com/signup
获取 token: https://dashboard.ngrok.com/get-started/your-authtoken
配置文件路径: ~/.openclaw/openclaw.json
gateway 部分需要以下配置:
2 "gateway": {
3 "port": 18789,
4 "mode": "local",
5 "bind": "lan",
6 "trustedProxies": ["127.0.0.1/32"],
7 "controlUi": {
8 "allowedOrigins": ["*"]
9 },
10 "auth": {
11 "mode": "token",
12 "token": "你的token"
13 }
14 }
15}
关键配置说明:
○ bind: "lan" — 允许局域网访问(默认 loopback 只允许本地)
○ trustedProxies — 信任 ngrok 代理转发的请求头,否则会被当作不可信连接
○ allowedOrigins: ["*"] — 允许跨域访问
2openclaw gateway run --bind lan
或者用 service 方式:
ngrok 会输出一个公网 URL,类似: https://xxxx-xxxx.ngrok-free.dev
1. 打开 ngrok 给的公网 URL,会看到 OpenClaw 仪表盘
2. 填写连接信息:
- WebSocket URL:wss://xxxx-xxxx.ngrok-free.dev
- 网关令牌: 你的 gateway token
- 点击"连接"
3. 首次连接会提示 "pairing required",需要在电脑上批准设备
每个新设备/浏览器首次连接需要在电脑上批准,之后同一设备不再需要。
1. 查看待批准设备列表会显示 Pending 列表,包含 Request ID 和设备信息。
2. 批准设备例如:
批准后手机上重新点"连接"即可。
其他设备管理命令:○ openclaw devices list — 查看所有设备
○ openclaw devices reject — 拒绝配对请求
○ openclaw devices remove — 移除已配对设备
○ openclaw devices revoke — 撤销设备 token
○ ngrok 免费版每次启动会分配不同的 URL,需要重新在手机上填写
○ 每个新设备只需批准一次,配对信息会保存
○ ngrok 需要保持运行,关掉后远程就无法访问了
○ 如果网关启动报错 "gateway already running",先执行 openclaw gateway stop
如果觉得有收获,欢迎关注「知了星AI」,一起看 AI 能把内容创作带到哪里。
夜雨聆风