fix: 通知 SSE 长连接被 Nginx 60s 超时掐断

This commit is contained in:
2026-08-05 18:00:45 +08:00
parent 2a519a3714
commit 32343b271b
3 changed files with 35 additions and 13 deletions

View File

@@ -25,6 +25,22 @@ server {
add_header Cache-Control "no-cache";
}
# SSE 长连接:禁用代理缓冲并放宽读写超时,避免 60s 空闲被掐断
location ~ ^/api/(notifications/stream|attendance-records/import/dingtalk/stream|ai/chat/.*/stream)$ {
proxy_pass http://backend:3000;
proxy_http_version 1.1;
proxy_set_header Connection "";
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_buffering off;
proxy_cache off;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
add_header X-Accel-Buffering no;
}
location /api/ {
proxy_pass http://backend:3000/api/;
proxy_set_header Host $host;