无公网IP解决方案:内网穿透访问OpenClaw+Qwen3-32B镜像 无公网IP解决方案内网穿透访问OpenClawQwen3-32B镜像1. 问题背景与核心挑战上周我在本地RTX4090D服务器上部署了Qwen3-32B-Chat镜像并通过OpenClaw搭建了自动化工作流。但当需要在外网通过飞书机器人触发任务时发现服务器没有公网IP这个致命问题——运营商不给家庭宽带分配公网IPv4地址已成常态。传统解决方案是申请云服务器做跳板但考虑到模型推理需要24GB显存云实例成本过高敏感数据不希望经过第三方服务器 最终选择了内网穿透方案。经过实测用frp自签证书的组合实现了安全稳定的外网访问。下面分享具体实施过程。2. 穿透方案选型与技术对比2.1 常见穿透工具横评测试了三种主流方案Ngrok配置简单但免费版不稳定企业版需要备案ZeroTierP2P穿透成功率高但需要客户端安装FRP自主可控支持HTTPS与TCP多协议最终选择FRP的核心原因可完全自托管用学生机做中转服务器支持流量加密与身份验证对OpenClaw的WebSocket协议兼容性好2.2 网络拓扑设计我的实际环境[外网设备] ←HTTPS→ [云服务器(1核1G)] ←加密隧道→ [内网RTX4090D服务器]关键配置参数云服务器腾讯云轻量级上海区域年费约65元带宽限制峰值5Mbps足够传输文本类指令流量加密TLS 1.3 AES-256-GCM3. 具体实施步骤3.1 FRP服务端配置在云服务器上安装frpswget https://github.com/fatedier/frp/releases/download/v0.54.0/frp_0.54.0_linux_amd64.tar.gz tar -zxvf frp_0.54.0_linux_amd64.tar.gz cd frp_0.54.0_linux_amd64编辑frps.ini[common] bind_port 7000 authentication_method token token your_secure_token_here启动服务nohup ./frps -c ./frps.ini frps.log 21 3.2 本地客户端配置在内网服务器操作cd frp_0.54.0_linux_amd64编辑frpc.ini[common] server_addr your_vps_ip server_port 7000 token your_secure_token_here [openclaw_web] type http local_port 18789 custom_domain openclaw.yourdomain.com [openclaw_ws] type tcp local_port 18790 remote_port 18790启动客户端nohup ./frpc -c ./frpc.ini frpc.log 21 4. HTTPS安全加固4.1 证书申请Lets Encrypt在云服务器执行sudo apt install certbot sudo certbot certonly --standalone -d openclaw.yourdomain.com获得证书后修改frps配置vhost_http_port 80 vhost_https_port 4434.2 Nginx反向代理配置/etc/nginx/conf.d/openclaw.confserver { listen 443 ssl; server_name openclaw.yourdomain.com; ssl_certificate /etc/letsencrypt/live/openclaw.yourdomain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/openclaw.yourdomain.com/privkey.pem; location / { proxy_pass http://127.0.0.1:80; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } }5. 飞书机器人外网回调5.1 飞书开放平台配置进入开发者后台在事件订阅添加请求网址https://openclaw.yourdomain.com/feishu/callback启用消息与事件权限5.2 OpenClaw配置调整修改~/.openclaw/openclaw.json{ channels: { feishu: { enabled: true, appId: your_app_id, appSecret: your_app_secret, connectionMode: webhook, webhook: { path: /feishu/callback, encryptKey: your_encrypt_key } } } }重启服务openclaw gateway restart6. 稳定性优化实践6.1 系统服务化防止进程退出创建/etc/systemd/system/frpc.service[Unit] DescriptionFRP Client Afternetwork.target [Service] Typesimple Usernobody Restarton-failure ExecStart/path/to/frpc -c /path/to/frpc.ini [Install] WantedBymulti-user.target启用服务sudo systemctl enable frpc sudo systemctl start frpc6.2 网络质量监控用tcping定时检测while true; do tcping -t 2 openclaw.yourdomain.com 443 connectivity.log sleep 60 done7. 效果验证与性能测试通过外网设备发起三项测试Web控制台访问Chrome访问https://openclaw.yourdomain.com平均加载时间1.8秒飞书指令触发发送整理本周会议记录指令端到端延迟2.3秒大模型推理测试执行32k上下文问答吞吐量维持在内网直连的92%获取更多AI镜像想探索更多AI镜像和应用场景访问 CSDN星图镜像广场提供丰富的预置镜像覆盖大模型推理、图像生成、视频生成、模型微调等多个领域支持一键部署。