From a95fe2d73f28c77a78d6bd256c8facaa92905aab Mon Sep 17 00:00:00 2001 From: 2910410219 <2910410219@qq.com> Date: Fri, 21 Aug 2026 14:58:02 +0800 Subject: [PATCH] =?UTF-8?q?nginx=20=E5=8F=8D=E5=90=91=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E9=80=8F=E4=BC=A0=20WebSocket=20=E5=8D=87=E7=BA=A7=E5=A4=B4?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E9=A6=96=E9=A1=B5=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E9=95=BF=E8=BF=9E=E6=8E=A5=E6=8F=A1=E6=89=8B=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 客户端 wsExecute 握手缺少 'upgrade' token in 'Connection' header,在 @proxy 增加 Upgrade/Connection 头透传。 Co-Authored-By: Claude --- ngnix.conf | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ngnix.conf b/ngnix.conf index 9630316..876fac8 100644 --- a/ngnix.conf +++ b/ngnix.conf @@ -6,6 +6,12 @@ map $http_user_agent $badbot { ~*(GPTBot|ChatGPT-User|Claude-Web|ClaudeBot|Bytespider|CCBot|Google-Extended) 1; } +# WebSocket 升级头透传:客户端带 Upgrade 头(WS 握手)时 Connection 置 upgrade,普通 REST 请求保持 close +map $http_upgrade $connection_upgrade { + default upgrade; + '' close; +} + # 主站 HTTP(SSL 已在外层 nginx 终结,此处只需 serve 内容) server { root /usr/share/nginx/html; @@ -59,6 +65,9 @@ server { 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 升级头透传(首页会话长连接 /ai-agent/session/wsExecute 依赖握手成功) + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; proxy_connect_timeout 75s; proxy_send_timeout 86400s; proxy_read_timeout 86400s; @@ -203,6 +212,9 @@ server { 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 升级头透传(首页会话长连接 /ai-agent/session/wsExecute 依赖握手成功) + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; proxy_connect_timeout 75s; proxy_send_timeout 86400s; proxy_read_timeout 86400s;