This commit is contained in:
hailin 2025-06-19 18:38:08 +08:00
parent 6a7e5eec2e
commit e68f4b3693
1 changed files with 7 additions and 12 deletions

View File

@ -1,9 +1,9 @@
upstream apiv1 { upstream apiv11 {
server 127.0.0.1:8084; server 127.0.0.1:8084;
keepalive 64; keepalive 64;
} }
upstream chatws { upstream chatws1 {
server 127.0.0.1:8084; server 127.0.0.1:8084;
keepalive 64; keepalive 64;
} }
@ -11,12 +11,13 @@ upstream chatws {
server { server {
server_name updsrv.szaiai.com; server_name updsrv.szaiai.com;
client_max_body_size 100M; # 这里设置确保适用于所有 HTTPS 请求 client_max_body_size 100M;
location / { location / {
return 404; return 404;
} }
# 普通 HTTP 请求处理,不支持 WebSocket
location ^~/api/v1 { location ^~/api/v1 {
proxy_redirect off; proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
@ -26,13 +27,10 @@ server {
proxy_set_header X-NginX-Proxy true; proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection ""; proxy_set_header Connection "";
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_pass http://apiv1; proxy_pass http://apiv11;
}
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
} }
# 仅此处启用 WebSocket 支持
location ^~ /api/v1/deploy/ws/ { location ^~ /api/v1/deploy/ws/ {
proxy_redirect off; proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
@ -42,11 +40,8 @@ server {
proxy_set_header X-NginX-Proxy true; proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection ""; proxy_set_header Connection "";
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_pass http://chatws;
## 以下两个配置如果没配置websocket会报错链接时使用wss://
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";
proxy_pass http://chatws1;
} }
} }