diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index 4cc39e11c4..dc61ad5cd7 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -1226,6 +1226,11 @@ TERMINAL_SERVER_CONNECTIONS = PersistentConfig( terminal_server_connections, ) +try: + TERMINAL_PROXY_HEADERS = json.loads(os.environ.get('TERMINAL_PROXY_HEADERS', '{}')) +except Exception: + TERMINAL_PROXY_HEADERS = {} + #################################### # WEBUI #################################### diff --git a/backend/open_webui/routers/terminals.py b/backend/open_webui/routers/terminals.py index 003db06968..c251b20d48 100644 --- a/backend/open_webui/routers/terminals.py +++ b/backend/open_webui/routers/terminals.py @@ -17,6 +17,7 @@ from starlette.background import BackgroundTask from open_webui.utils.auth import get_verified_user from open_webui.utils.access_control import has_connection_access from open_webui.env import AIOHTTP_CLIENT_SESSION_SSL +from open_webui.config import TERMINAL_PROXY_HEADERS from open_webui.models.groups import Groups from open_webui.models.users import Users @@ -151,6 +152,8 @@ async def proxy_terminal( for key, value in upstream_response.headers.items() if key.lower() not in STRIPPED_RESPONSE_HEADERS } + if TERMINAL_PROXY_HEADERS: + filtered_headers.update(TERMINAL_PROXY_HEADERS) # Stream binary responses directly if any(t in upstream_content_type for t in STREAMING_CONTENT_TYPES):