这个方案,OpenClaw必须要部署在公网服务器上,部署在本地不行,其实也不是不行,但要设置NAT穿越,比较复杂,所以不建议部署在本地。
废话不多说,直接上教程。
01
OpenClaw配置成公网
多数人使用OpenClaw的网页,其实都是用的本地局域网地址:127.0.0.1
但其实可以配置成服务器公网的地址。
如果你是在百度云厂商上搭建的,就不存在这个问题。这一步针对自己租服务器搭建的场景,比如我就是租的云服务器去部署openclaw
打开OpenClaw.json文件,需要修改如下几个选项
“gateway”: {
“port”: 18789,
“mode”: “local”,
“bind”: “lan”,
“controlUi”: {
“allowedOrigins”: [
“http://192.168.58.118:18789”
],
“allowInsecureAuth”:true,
“dangerouslyDisableDeviceAuth”:true
},
“auth”: {
“mode”: “password”,
“token”: “xxxxxxxx”,
“password”: “xxxx”
},
“tailscale”: {
“mode”: “off”,
“resetOnExit”: false
},
“remote”: {
“url”: “ws://0.0.0.0:18789”,
“token”: “xxxxxxxx”
},
“nodes”: {
“denyCommands”: [
“camera.snap”,
“camera.clip”,
“screen.record”,
“calendar.add”,
“contacts.add”,
“reminders.add”
]
}
},
bind从loopback改成lan, 这样就从127.0.0.1变成使用公网IP。
增加controlUi选项,其中allowedOrigins配置你的公网IP。
allowInsecureAuth和dangerouslyDisableDeviceAuth设置为True, 这2个参数的意义是用HTTP的方式也能访问,不需要HTTPS。如果配置HTTPS的话,还的配置安全证书,比较麻烦
当然HTTP的方式的安全度不高,所以不要泄露自己的IP以及token。
配置完成后执行:openclaw gateway restart 重启生效
通过公网地址打开网页,状态显示Connected,就表示公网gateway地址是通的了。



























