taskkill /F /IM nginx.exe

This commit is contained in:
zqm
2026-03-20 16:51:31 +08:00
parent 6e0b5aa056
commit ed54296f62
11 changed files with 1190 additions and 766 deletions

View File

@@ -40,9 +40,9 @@ http {
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# 企业微信回调 - 网关服务API
# 企业微信回调 - 直接代理到网关服务
location /wecom {
proxy_pass http://127.0.0.1:8000/api/v1/wechat/callback;
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -94,6 +94,25 @@ http {
proxy_cache off;
}
# WebSocket控制通道 - SmartClaw服务连接API路径
location /api/v1/ws/control {
proxy_pass http://127.0.0.1:8000;
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 $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket特殊超时设置
proxy_read_timeout 86400s; # 24小时支持长连接
proxy_connect_timeout 10s;
# 禁用缓存
proxy_cache off;
}
# WebSocket任务通道
location /ws/task {
proxy_pass http://127.0.0.1:8000;
@@ -113,6 +132,25 @@ http {
proxy_cache off;
}
# WebSocket任务通道API路径
location /api/v1/ws/task {
proxy_pass http://127.0.0.1:8000;
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 $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket特殊超时设置
proxy_read_timeout 86400s; # 24小时支持长连接
proxy_connect_timeout 10s;
# 禁用缓存
proxy_cache off;
}
# Web前端静态文件
location / {
root C:/Claw/web; # 指向Web前端构建目录

180
Claw/docs/nginx_backup.conf Normal file
View File

@@ -0,0 +1,180 @@
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# 日志配置
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
error_log logs/error.log;
# HTTP 自动跳 HTTPS
server {
listen 80;
server_name pactgo.cn;
return 301 https://$host$request_uri;
}
# HTTPS 服务器 - 网关服务
server {
listen 443 ssl;
server_name pactgo.cn;
# SSL证书配置
ssl_certificate C:/nginx/ssl/pactgo.cn-chain.pem;
ssl_certificate_key C:/nginx/ssl/pactgo.cn-key.pem;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# 企业微信回调 - 直接代理到网关服务
location /wecom {
proxy_pass http://127.0.0.1:8000;
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;
# 企业微信回调特殊处理
proxy_read_timeout 30s;
proxy_connect_timeout 10s;
}
# 微信小程序回调 - 网关服务API
location /api/v1/wechat/miniprogram/callback {
proxy_pass http://127.0.0.1:8000;
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;
}
# 网关服务其他API
location /api/ {
proxy_pass http://127.0.0.1:8000;
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;
# API超时设置
proxy_read_timeout 60s;
proxy_connect_timeout 10s;
}
# WebSocket控制通道 - SmartClaw服务连接
location /ws/control {
proxy_pass http://127.0.0.1:8000;
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 $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket特殊超时设置
proxy_read_timeout 86400s; # 24小时支持长连接
proxy_connect_timeout 10s;
# 禁用缓存
proxy_cache off;
}
# WebSocket控制通道 - SmartClaw服务连接API路径
location /api/v1/ws/control {
proxy_pass http://127.0.0.1:8000;
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 $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket特殊超时设置
proxy_read_timeout 86400s; # 24小时支持长连接
proxy_connect_timeout 10s;
# 禁用缓存
proxy_cache off;
}
# WebSocket任务通道
location /ws/task {
proxy_pass http://127.0.0.1:8000;
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 $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket特殊超时设置
proxy_read_timeout 86400s; # 24小时支持长连接
proxy_connect_timeout 10s;
# 禁用缓存
proxy_cache off;
}
# WebSocket任务通道API路径
location /api/v1/ws/task {
proxy_pass http://127.0.0.1:8000;
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 $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket特殊超时设置
proxy_read_timeout 86400s; # 24小时支持长连接
proxy_connect_timeout 10s;
# 禁用缓存
proxy_cache off;
}
# Web前端静态文件
location / {
root C:/Claw/web; # 指向Web前端构建目录
index index.html index.htm;
try_files $uri $uri/ /index.html;
# 静态文件缓存
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}
# 健康检查端点
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
}
# 上游服务器配置
upstream gateway_backend {
server 127.0.0.1:8000 max_fails=3 fail_timeout=30s;
keepalive 32;
}
}

View File

@@ -1,59 +0,0 @@
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# HTTP 自动跳 HTTPS
server {
listen 80;
server_name pactgo.cn;
return 301 https://$host$request_uri;
}
# HTTPS 服务器
server {
listen 443 ssl;
server_name pactgo.cn;
ssl_certificate C:/nginx/ssl/pactgo.cn-chain.pem;
ssl_certificate_key C:/nginx/ssl/pactgo.cn-key.pem;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location /wecom {
proxy_pass http://127.0.0.1:8000/api/v1/wechat/callback;
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;
# 企业微信回调特殊处理
proxy_read_timeout 30s;
proxy_connect_timeout 10s;
}
# WebSocket 支持
location /ws {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location / {
root html;
index index.html index.htm;
}
}
}

View File

@@ -93,9 +93,16 @@ sequenceDiagram
**WebSocket长连接方案**(推荐):
1. **SmartClaw服务主动连接**服务器B启动时主动WebSocket连接到服务器A
2. **长连接保持**:维持持久WebSocket连接支持心跳检测
3. **双向通信**服务器A通过WebSocket发送任务服务器B处理完成后回传结果
4. **断线重连**:自动重连机制,保证连接稳定性
2. **单一连接**服务器B与服务器A之间只建立一个WebSocket连接不需要列表管理
3. **长连接保持**维持持久WebSocket连接支持心跳检测
4. **双向通信**服务器A通过WebSocket发送任务服务器B处理完成后回传结果
5. **断线重连**:自动重连机制,保证连接稳定性
### 4.2.1 WebSocket连接管理
- **服务器B与服务器A**只建立一个WebSocket连接无需列表管理
- **其他设备与服务器A**通过WebSocket连接到服务器A的 `/ws/task` 路径,需要使用连接列表进行管理
- **连接管理**:使用 `ConnectionManager` 结构体管理设备与服务器A的WebSocket连接支持多用户多设备场景
**优点**