Skip to content

Commit 5a60ea6

Browse files
authored
Modify Nginx config for WebSocket connection handling
Updated the Nginx configuration to handle WebSocket upgrades correctly by using a map for the Connection header.
1 parent 8d8702c commit 5a60ea6

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

base/nginx/configmap.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ data:
88
worker_connections 1024;
99
}
1010
http {
11+
# Only send "Connection: upgrade" when the client actually initiated a
12+
# WebSocket upgrade. For plain GETs, send "Connection: close". Required
13+
# when an HTTP/2 frontend (Caddy) sits in front of this nginx — HTTP/2
14+
# forbids hop-by-hop Connection: upgrade headers and will abort the
15+
# response with ERR_HTTP2_PROTOCOL_ERROR otherwise (symptom: JS chunks
16+
# fail to load, LiteLLM UI stuck on "Loading...").
17+
map $http_upgrade $connection_upgrade {
18+
default upgrade;
19+
'' close;
20+
}
21+
1122
upstream litellm_backend {
1223
server litellm-service.litellm.svc.cluster.local:4000;
1324
}
@@ -34,7 +45,7 @@ data:
3445
3546
# Streaming and WebSocket support
3647
proxy_set_header Upgrade $http_upgrade;
37-
proxy_set_header Connection "upgrade";
48+
proxy_set_header Connection $connection_upgrade;
3849
proxy_buffering off;
3950
proxy_read_timeout 300s;
4051

0 commit comments

Comments
 (0)