OpenClaw 腾讯云服务本地访问配置指南本文介绍如何在腾讯云服务器上配置 OpenClaw 服务通过 Nginx 反向代理实现公网访问。目录1. 安装 Nginx2. 创建 Nginx 配置文件3. 启用配置并测试4. 配置 OpenClaw 可信代理5. 配置防火墙6. 配置 HTTPS 证书1. 安装 Nginx根据你的发行版执行对应命令Ubuntu / Debiansudoaptinstall-ynginxCentOS / RHELsudoyuminstall-ynginx启动并设置开机自启sudosystemctl start nginxsudosystemctlenablenginx2. 创建 Nginx 配置文件创建配置文件sudovim/etc/nginx/sites-available/openclaw.conf将以下内容粘贴进去替换your-domain.com为你自己的域名server { listen 80; server_name your-domain.com; location / { proxy_pass http://127.0.0.1:18789; proxy_http_version 1.1; 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_connect_timeout 60s; proxy_send_timeout 60s; proxy_read_timeout 60s; } }3. 启用配置并测试创建软链接sudoln-s/etc/nginx/sites-available/openclaw.conf /etc/nginx/sites-enabled/测试配置正确性sudonginx-t如果输出显示test is successful说明配置没问题执行重载sudosystemctl reload nginx4. 配置 OpenClaw 可信代理编辑 OpenClaw 配置文件~/.openclaw/openclaw.json在gateway区块下添加/修改以下配置{gateway:{port:18789,mode:local,bind:lan,trustedProxies:[127.0.0.1],controlUi:{allowedOrigins:[http://localhost:18789,http://127.0.0.1:18789,http://你的服务器IP:18789,https://www.your-domain.com,https://your-domain.com],dangerouslyDisableDeviceAuth:true,allowInsecureAuth:true}}}根据实际情况修改allowedOrigins中的域名和IP列表添加你自己的访问地址。修改配置后需要重启 OpenClaw 服务生效openclaw gateway restart5. 配置防火墙登录腾讯云控制台在安全组中开放80(HTTP) 和443(HTTPS) 端口。如果服务器本地也启用了ufw或firewalld也需要同步开放这两个端口ufw (Ubuntu/Debian):sudoufw allow80/tcpsudoufw allow443/tcp6. 配置 HTTPS 证书使用 Certbot 申请免费的 Let’s Encrypt 证书安装 Certbotsudoaptinstall-ycertbot python3-certbot-nginx申请证书并自动配置 Nginxsudocertbot--nginx-dyour-domain.com按照提示完成操作Certbot 会自动修改 Nginx 配置并启用 HTTPS。测试自动续期Let’s Encrypt 证书有效期为 90 天Certbot 一般会自动续期。你可以手动测试sudocertbot renew --dry-run完成以上步骤后就可以通过https://你的域名公网访问部署在腾讯云上的 OpenClaw 服务了。
OpenClaw 腾讯云服务本地访问配置指南
OpenClaw 腾讯云服务本地访问配置指南本文介绍如何在腾讯云服务器上配置 OpenClaw 服务通过 Nginx 反向代理实现公网访问。目录1. 安装 Nginx2. 创建 Nginx 配置文件3. 启用配置并测试4. 配置 OpenClaw 可信代理5. 配置防火墙6. 配置 HTTPS 证书1. 安装 Nginx根据你的发行版执行对应命令Ubuntu / Debiansudoaptinstall-ynginxCentOS / RHELsudoyuminstall-ynginx启动并设置开机自启sudosystemctl start nginxsudosystemctlenablenginx2. 创建 Nginx 配置文件创建配置文件sudovim/etc/nginx/sites-available/openclaw.conf将以下内容粘贴进去替换your-domain.com为你自己的域名server { listen 80; server_name your-domain.com; location / { proxy_pass http://127.0.0.1:18789; proxy_http_version 1.1; 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_connect_timeout 60s; proxy_send_timeout 60s; proxy_read_timeout 60s; } }3. 启用配置并测试创建软链接sudoln-s/etc/nginx/sites-available/openclaw.conf /etc/nginx/sites-enabled/测试配置正确性sudonginx-t如果输出显示test is successful说明配置没问题执行重载sudosystemctl reload nginx4. 配置 OpenClaw 可信代理编辑 OpenClaw 配置文件~/.openclaw/openclaw.json在gateway区块下添加/修改以下配置{gateway:{port:18789,mode:local,bind:lan,trustedProxies:[127.0.0.1],controlUi:{allowedOrigins:[http://localhost:18789,http://127.0.0.1:18789,http://你的服务器IP:18789,https://www.your-domain.com,https://your-domain.com],dangerouslyDisableDeviceAuth:true,allowInsecureAuth:true}}}根据实际情况修改allowedOrigins中的域名和IP列表添加你自己的访问地址。修改配置后需要重启 OpenClaw 服务生效openclaw gateway restart5. 配置防火墙登录腾讯云控制台在安全组中开放80(HTTP) 和443(HTTPS) 端口。如果服务器本地也启用了ufw或firewalld也需要同步开放这两个端口ufw (Ubuntu/Debian):sudoufw allow80/tcpsudoufw allow443/tcp6. 配置 HTTPS 证书使用 Certbot 申请免费的 Let’s Encrypt 证书安装 Certbotsudoaptinstall-ycertbot python3-certbot-nginx申请证书并自动配置 Nginxsudocertbot--nginx-dyour-domain.com按照提示完成操作Certbot 会自动修改 Nginx 配置并启用 HTTPS。测试自动续期Let’s Encrypt 证书有效期为 90 天Certbot 一般会自动续期。你可以手动测试sudocertbot renew --dry-run完成以上步骤后就可以通过https://你的域名公网访问部署在腾讯云上的 OpenClaw 服务了。