From a756d45cb2a6cd985701e08d216c0645ec497a3c Mon Sep 17 00:00:00 2001 From: Sebastian <379651+czarly@users.noreply.github.com> Date: Sat, 9 Nov 2024 04:56:53 +0100 Subject: [PATCH] do not drop websocket connections --- nginx-proxy/default.conf.template | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/nginx-proxy/default.conf.template b/nginx-proxy/default.conf.template index 9e54bc35..bfd3f248 100644 --- a/nginx-proxy/default.conf.template +++ b/nginx-proxy/default.conf.template @@ -3,6 +3,11 @@ map $http_upgrade $proxy_connection { websocket "ws_backend${WS_PATH}"; } +map $http_upgrade $is_websocket { + default 0; + websocket 1; +} + server { listen 80; server_name _; @@ -17,9 +22,9 @@ server { proxy_set_header Connection $http_connection; # Forward Connection header # Ensure the connection stays open indefinitely on websockets - proxy_read_timeout $http_upgrade websocket 3600s; - proxy_send_timeout $http_upgrade websocket 3600s; - + proxy_read_timeout $is_websocket ? 3600s : 60s; + proxy_send_timeout $is_websocket ? 3600s : 60s; + proxy_connect_timeout 60s; # Disable buffering for real-time traffic