openclaw离线部署

环境准备:

系统ubuntu24.04
node版本>=22

openclaw安装方式有在线安装和离线安装两种方式

一、在线安装,可执行如下命令:

curl -fsSL https://openclaw.ai/install.sh | bash   #一键安装

npm install -g openclaw@latest  #全局安装

openclaw onboard --install-daemon   #新手向导安装

问题一:登录页面后提示错误:

origin not allowed (open the Control UI from the gateway host or allow it in gateway.controlUi.allowedOrigins

OpenClaw 默认只允许从 Gateway 所在机器的本地(127.0.0.1/localhost)访问控制面板,当你从其他 IP(比如局域网、外网)访问时,就会触发这个「跨域 / 来源限制」报错,解决方案:

首先切换到openclaw用户,修改openclaw.json文件,修改允许跨域,如图:

问题二:页面提示:

control ui requires device identity (use HTTPS or localhost secure context)

这个报错是浏览器的安全策略限制,而非 OpenClaw 本身的配置问题,OpenClaw 的控制面板(Control UI)需要「安全上下文(Secure Context)」才能获取设备标识(Device Identity),而浏览器仅认为以下两种场景是「安全的」:

  • localhost/127.0.0.1(本机访问)
  • HTTPS 加密访问(非本机 / 外网访问)

解决方案:

1、直接在openclaw部署机器上通过localhost访问,但如果在Linux上部署,又在其他机器上访问,显然这种方式不适合

2、配置https,可通过nginx代理到后端的openclaw机器上,如下:

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  ssl_certificate  /etc/nginx/cert/openclaw.test.com.crt;
  ssl_certificate_key /etc/nginx/cert/openclaw.test.com.key;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  ssl_prefer_server_ciphers on;
  ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK;
  ssl_session_timeout 10m;
  ssl_session_cache builtin:1000 shared:SSL:10m;
  ssl_buffer_size 1400;
  add_header Strict-Transport-Security max-age=15768000;
  add_header Access-Control-Allow-Origin *;
  add_header Access-Control-Allow-Methods "GET, POST, OPTIONS, PUT, DELETE";
  add_header Access-Control-Allow-Headers "X-Requested-With, Content-Type, Authorization";
  server_name openclaw.test.com;
  location / {
	proxy_pass http://127.0.0.1:18789;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        # WebSocket 核心配置(必须加,否则连接断开)
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 86400;
  }
}

问题三、页面提示如下:

unauthorized: gateway password missing (enter the password in Control UI settings)

报错为没有连接gateway,在概览界面,输入在安装openclaw过程中配置的gateway密码即可,如图:

问题四:提示pairing required

pairing required 是 OpenClaw 的设备配对安全机制:新设备 / 浏览器首次连接时,必须在服务端手动批准才能接入,解决方案:

1、查看待批准的设备(在openclaw部署的服务器上执行),如下:

openclaw devices list   

注:Request是请求待批准的设备

2、执行如下命令批准,如下:

openclaw devices approve ca6393dd-abdf-4dea-9320-15d9d2ed5026

3、最后重启gateway即可,如下:

openclaw gateway restart

4、openclaw的页面也可以看到当前状态为正常,如图:

标签