Environment Variables
Ambient mode reads its configuration from the environment at install time. Managed mode does not.
#Variables
| Variable | Used for | Notes |
|---|---|---|
HTTP_PROXY | proxy for http: and ws: URLs | upper case wins over lower |
HTTPS_PROXY | proxy for https: and wss: URLs | |
ALL_PROXY | fallback when the protocol-specific variable is unset | |
NO_PROXY | comma- or whitespace-separated list of exemptions | matched against the destination URL |
http_proxy | lowercase alias for HTTP_PROXY | upper case wins when both are set |
https_proxy | lowercase alias | |
all_proxy | lowercase alias | |
no_proxy | lowercase alias |
Empty or whitespace-only values are treated as unset.
#Activation
The ambient runtime is active when any of HTTP_PROXY, HTTPS_PROXY, or ALL_PROXY (or their lowercase forms) is set to a non-empty value.
NO_PROXY alone does not activate the runtime. With only NO_PROXY set, proxy.active is false and Proxyline installs no patches.
#Snapshot at install
The values are read once at installProxyline time. Changing process.env.HTTP_PROXY afterwards does not retroactively activate or reconfigure Proxyline. Call proxy.stop() and re-install if the environment changes.
#Proxy URL parsing
- Bare endpoints (no scheme) default to
http://.HTTPS_PROXY=proxy.corp:8080becomeshttp://proxy.corp:8080. http://andhttps://are the only accepted schemes. Anything else is ignored.- Userinfo (
user:pass@) in the proxy URL becomes aProxy-Authorization: Basicheader.
#NO_PROXY matching
Entries are split on commas and whitespace. Matching rules, in order:
*alone matches everything. The URL goes direct.- Entries can include a port:
internal.corp:8443. When present, the entry only matches the URL's port (defaulting to80forhttp/wsand443forhttps/wss). - Entries starting with
.or*are suffix matches..corp.examplematchesapi.corp.exampleandcorp.example.*.corp.exampleis equivalent. - Other entries are exact host matches.
- IPv6 entries may be bracketed (
[::1]:8443) or bare (::1). Bracketed forms are stripped before comparison. - Hostnames are lowercased and trailing dots are stripped before comparison.
When a URL matches NO_PROXY, explain() returns kind: "direct", reason: "no-proxy-match".
#Examples
# go through the proxy for everything except internal hosts
export HTTPS_PROXY="https://proxy.corp.example:8443"
export NO_PROXY=".corp.example,localhost,127.0.0.1,::1"
# only https traffic via proxy, http stays direct
export HTTPS_PROXY="https://proxy.corp.example:8443"
# fall through to ALL_PROXY for everything
export ALL_PROXY="socks-not-supported://example" # ignored — only http/https proxies are honored
export ALL_PROXY="http://gateway.corp:3128" # used for both http and https URLs
#Interaction with fetch
The undici global dispatcher is installed as EnvHttpProxyAgent in ambient mode and is configured with the exact same HTTP_PROXY / HTTPS_PROXY / NO_PROXY snapshot Proxyline read at install time. fetch and node:http therefore agree on the proxy decision for any URL.