From c955cbd2c5ca6c567cc8ca11e2dd26949d8f63ac Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Wed, 9 Sep 2026 18:31:02 +0200 Subject: [PATCH] fix: stop forwarding upstream Server and Date headers from the terminal proxy (#29841) Proxied terminal responses (GET /api/v1/terminals/{id}/ports and every other proxied route) went out with two Server and two Date headers: the terminal server's copies, forwarded verbatim, plus uvicorn's own. nginx in front of Open WebUI logs "upstream sent duplicate header line" for both on every request, and the ports route is polled often enough to fill gigabytes of error log per day. Server and Date belong to whoever terminates the connection, so the proxy now drops the upstream's copies next to the framing headers it already stripped. uvicorn's own values still go out, once. Everything else, including custom upstream headers and TERMINAL_PROXY_HEADERS, passes through unchanged. The OpenAI and Ollama proxies forward upstream Server and Date the same way and are left for a separate change. Fixes #29824 --- backend/open_webui/routers/terminals.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/routers/terminals.py b/backend/open_webui/routers/terminals.py index 6a428bfcb4..ee790d3ac1 100644 --- a/backend/open_webui/routers/terminals.py +++ b/backend/open_webui/routers/terminals.py @@ -39,7 +39,10 @@ log = logging.getLogger(__name__) router = APIRouter() STREAMING_CONTENT_TYPES = ('application/octet-stream', 'image/', 'application/pdf') -STRIPPED_RESPONSE_HEADERS = frozenset(('transfer-encoding', 'connection', 'content-encoding', 'content-length')) +# Drop the upstream's server and date: uvicorn adds its own and forwarding both duplicates them. +STRIPPED_RESPONSE_HEADERS = frozenset( + ('transfer-encoding', 'connection', 'content-encoding', 'content-length', 'server', 'date') +) def _sanitize_proxy_path(path: str) -> str | None: