Add upstream proxy - #104
Conversation
| By default httpjail contacts destination servers directly. When httpjail itself | ||
| runs in an environment that has no direct internet access — for example behind a | ||
| corporate proxy — you can route httpjail's own outbound requests through an | ||
| upstream proxy with `--upstream-proxy` (or the `HTTPJAIL_UPSTREAM_PROXY` |
There was a problem hiding this comment.
Why shouldn't httpjail itself respect the standard HTTP_PROXY variables? I think it's clear on its face it wouldn't pass that down to children (as that would invalidate the whole point of the jail).
There was a problem hiding this comment.
Agreed. For the first release, I’ll remove --upstream-proxy and HTTPJAIL_UPSTREAM_PROXY and use the standard HTTP_PROXY / HTTPS_PROXY environment variables for httpjail’s own egress.
Adding a dedicated CLI option and httpjail-specific env var creates an extra configuration path before we have a concrete need for it. If we later need an explicit per-invocation override, we can add it in a follow-up change.
There was a problem hiding this comment.
@ammario following up on 701d116, which drops --upstream-proxy / HTTPJAIL_UPSTREAM_PROXY in favor of the standard HTTP_PROXY / HTTPS_PROXY for httpjail's own egress.
One question: did you intend for the dedicated flag and env var to be removed entirely, or kept as an explicit override alongside HTTP_PROXY? I went with full removal, but it's easy to bring back either way. Let me know how this looks.
Remove the upstream proxy CLI option and httpjail-specific environment variable, and resolve httpjail's own upstream proxy from HTTP_PROXY and HTTPS_PROXY instead. Also keep the new upstream proxy initialization logs at debug level so normal CLI output is not affected.
|
I reviewed this against the latest
For complexity cleanup, the manual Local verification: formatting and — Codex, AI review agent |
Summary
Adds support for routing httpjail's outbound requests through an upstream proxy using the standard
HTTP_PROXYandHTTPS_PROXYenvironment variables.Motivation
I want to run httpjail behind a corporate proxy. Without upstream proxy support, httpjail connects directly to destination hosts, which fails in environments where direct egress is blocked.
What this does
HTTP_PROXYfor HTTP destinations.HTTPS_PROXYfor HTTPS destinations.http_proxyandhttps_proxyvariants.http://,https://, and barehost:portproxy addresses.CONNECTtunnel and forwards plain HTTP requests in absolute-form.Proxy configuration is environment-only; no additional command-line option is introduced. Behavior is unchanged when neither proxy environment variable is configured.
Usage
Route HTTPS requests through a corporate proxy:
Route both HTTP and HTTPS requests through the same proxy:
Proxy credentials and HTTPS proxies are also supported:
Manual verification
Given rules allowing only
github.com:Allowed request
Blocked request