Skip to content

Honor HTTP(S)_PROXY in the default HTTP client#253

Closed
yotamazriel wants to merge 1 commit into
masterfrom
fix-proxy-aware-http-client
Closed

Honor HTTP(S)_PROXY in the default HTTP client#253
yotamazriel wants to merge 1 commit into
masterfrom
fix-proxy-aware-http-client

Conversation

@yotamazriel

Copy link
Copy Markdown
Member

Problem

init() in pkg/api/utils.go replaces Go's global http.DefaultClient with a client built on a bare http.Transport{} (no Proxy set). Every http.Get in the binary — including the bundled helm-charts installer's GetReleasesPage — therefore silently ignores HTTP_PROXY / HTTPS_PROXY / NO_PROXY.

Behind a corporate proxy (no direct internet egress), leap server install fails with:

Get "https://api.github.com/repos/tensorleap/helm-charts/releases?page=1&per_page=100":
dial tcp: lookup api.github.com on 127.0.0.53:53: no such host

even when the proxy env vars are set correctly. Confirmed root cause: curl using the exact same env reaches GitHub (200), while leap does a direct DNS lookup — because its http.DefaultClient has no proxy.

Fix

Set Proxy: http.ProxyFromEnvironment on the transport in NewDefaultClient(). This restores standard proxy support for the whole binary.

It also clears the misleading No internet connection found warning, since hasInternet() (cmd/server/utils.go) uses the same client.

Testing

Built for linux/amd64 and verified on a customer host behind an authenticated Squid proxy: the GitHub release lookup now succeeds through the proxy, and the install proceeds.

🤖 Generated with Claude Code

init() replaces http.DefaultClient with a client built on a bare
http.Transport{}, which has no Proxy set. This makes every http.Get in
the binary (and the bundled helm-charts installer) ignore
HTTP_PROXY/HTTPS_PROXY/NO_PROXY, so installs behind a corporate proxy
fail with direct-DNS errors (e.g. resolving api.github.com) even when
the proxy env is set correctly.

Set Proxy: http.ProxyFromEnvironment on the transport. This also clears
the misleading "No internet connection found" warning, since
hasInternet() uses the same client.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant