mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 03:18:23 -05:00
[PR #23810] fix: honour HTTP proxy env vars for DuckDuckGo search and URL fetching #27383
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/23810
Author: @imoes
Created: 4/16/2026
Status: 🔄 Open
Base:
dev← Head:fix/corporate-proxy-web-search📝 Commits (3)
4b610a3fix: honour HTTP proxy env vars for DuckDuckGo search and URL fetchingcfca838fix: robustly detect HTTP proxy for DuckDuckGo search across ddgs versions0c68d26fix: pass HTTP proxy env vars to Tencent Cloud SDK in sougou.py📊 Changes
3 files changed (+36 additions, -7 deletions)
View changed files
📝
backend/open_webui/retrieval/web/duckduckgo.py(+14 -1)📝
backend/open_webui/retrieval/web/sougou.py(+10 -0)📝
backend/open_webui/retrieval/web/utils.py(+12 -6)📄 Description
Pull Request Checklist
devWEB_SEARCH_TRUST_ENVand standardhttp_proxy/https_proxybehaviour unchanged.proxy.ippen.media:80). Both DuckDuckGo search and URL fetching confirmed working after fix.dev.Problem
Web search failed when Open WebUI runs behind a corporate HTTP proxy with
http_proxy/https_proxyset as Docker environment variables.1. DuckDuckGo search (
duckduckgo.py)DDGS()was instantiated without aproxyargument, so all outgoing requests bypassed the proxy and were blocked.A partial fix (passing
proxy=os.environ.get("https_proxy")toDDGS()) worked with one version of theddgspackage but broke again when theghcr.io/open-webui/open-webui:mainimage was repulled with a newerddgsversion. The newer version uses a different internal httpx client configuration that requires uppercaseHTTPS_PROXY/HTTP_PROXYenv vars to reliably detect proxy settings.2. URL fetching after search (
utils.py)SafeWebBaseLoader._fetchcreated anaiohttp.ClientSessionwithtrust_enveffectively hardcoded toFalse. BecauseWEB_SEARCH_TRUST_ENVis managed viaPersistentConfig(database-backed), aFalsevalue stored in the DB on first run silently overrides theWEB_SEARCH_TRUST_ENV=trueenv var on every subsequent container restart.Fix
duckduckgo.pyhttps_proxy,HTTPS_PROXY,http_proxy,HTTP_PROXY).os.environ.setdefault()to ensure uppercaseHTTPS_PROXY/HTTP_PROXYare set beforeDDGSis instantiated, so httpx picks up the proxy automatically regardless of whichddgsversion is installed.DDGS(proxy=proxy)as well.utils.pytrust_env: bool = Falseparameter defaults toTrueacross all loader classes andget_web_loader().SafeWebBaseLoader._fetch, computeeffective_trust_env = self.trust_env or bool(os.environ.get("https_proxy") or os.environ.get("http_proxy"))so the aiohttp session always uses the proxy when proxy env vars are present, regardless of the DB-cached config value.Reproduction
Deploy Open WebUI in Docker with:
ConnectError; URL fetching →Connection timeoutChangelog Entry
Fixed
duckduckgo.py: Robustly detect HTTP proxy acrossddgsversions by reading all four proxy env var variants and ensuring uppercaseHTTPS_PROXY/HTTP_PROXYare set for httpx compatibility. Also pass proxy explicitly toDDGS(proxy=proxy).utils.py:SafeWebBaseLoader._fetchnow auto-enablestrust_envwhen proxy env vars are present, bypassing thePersistentConfigDB-cachedFalsevalue that would otherwise silently ignore the proxy.utils.py: Changedtrust_envdefault fromFalsetoTruein all loader classes andget_web_loader().Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.