Skip to content

Commit 1719702

Browse files
committed
feat(dgw,agent): add HTTP/SOCKS proxy configuration support
Adds configurable HTTP/HTTPS/SOCKS4/SOCKS5 proxy support for outbound requests in both Gateway and Agent. Proxy settings can be configured manually or auto-detected from system settings (WinHTTP on Windows, environment variables on Unix). This replaces reqwest's system-proxy feature with the proxy_cfg crate for better system integration and per-URL proxy selection, improving support for PAC files and complex enterprise proxy environments.
1 parent c3fd3f1 commit 1719702

File tree

17 files changed

+1520
-262
lines changed

17 files changed

+1520
-262
lines changed

Cargo.lock

Lines changed: 355 additions & 225 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,41 @@ Stable options are:
230230
* **StaticRootPath** (_FilePath_): Path to the static files for the standalone web application.
231231
This is an advanced option which should typically not be changed.
232232

233+
- **Proxy** (_Object_): HTTP/SOCKS proxy configuration for outbound requests.
234+
Supports three modes: Off (never use proxy), System (auto-detect), Manual (explicit configuration).
235+
236+
* **Mode** (_String_): Proxy mode (default is `System`).
237+
- `Off`: Never use a proxy, ignore environment variables
238+
- `System`: Auto-detect proxy from environment variables (HTTP_PROXY, HTTPS_PROXY, NO_PROXY)
239+
or system settings (per-user and machine-wide settings with WinHTTP fallback on Windows,
240+
`/etc/sysconfig/proxy` on RHEL/SUSE systems, SCDynamicStoreCopyProxies() on macOS)
241+
- `Manual`: Use explicitly configured proxy URLs
242+
243+
* **Http** (_URL_): HTTP proxy URL for `http://` requests (e.g., `http://proxy.corp:8080`).
244+
Only used when Mode is `Manual`.
245+
246+
* **Https** (_URL_): HTTPS proxy URL for `https://` requests (e.g., `http://proxy.corp:8080`).
247+
Only used when Mode is `Manual`.
248+
249+
* **All** (_URL_): Fallback proxy URL for all protocols (e.g., `socks5://proxy.corp:1080`).
250+
Only used when Mode is `Manual`.
251+
The URL scheme determines the proxy type:
252+
- `http://proxy.corp:8080` - HTTP CONNECT proxy
253+
- `socks5://proxy.corp:1080` - SOCKS5 proxy
254+
- `socks4://proxy.corp:1080` - SOCKS4 proxy
255+
256+
* **Exclude** (_Array of Strings_): Bypass list with NO_PROXY semantics (only used when Mode is `Manual`).
257+
Supports:
258+
- Wildcard: `*` (bypass proxy for all targets)
259+
- Exact hostname: `localhost`, `example.com`
260+
- Domain suffix: `.corp.local` (matches `foo.corp.local`)
261+
- IP address: `127.0.0.1`
262+
- CIDR range: `10.0.0.0/8`, `192.168.0.0/16`
263+
264+
Authentication can be included in proxy URLs: `http://username:password@proxy.corp:8080`
265+
266+
See the [Cookbook](./docs/COOKBOOK.md) for configuration examples.
267+
233268
- **VerbosityProfile** (_String_): Logging verbosity profile (pre-defined tracing directives).
234269

235270
Possible values:

config_schema.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696
"$ref": "#/definitions/AiGatewayConf",
9797
"description": "JSON object describing the AI gateway configuration (experimental, requires enable_unstable)."
9898
},
99+
"Proxy": {
100+
"$ref": "#/definitions/ProxyConf",
101+
"description": "HTTP/SOCKS proxy configuration for outbound requests."
102+
},
99103
"LogFile": {
100104
"type": "string",
101105
"description": "Path to the log file."
@@ -630,6 +634,38 @@
630634
},
631635
"additionalProperties": false
632636
},
637+
"ProxyConf": {
638+
"type": "object",
639+
"description": "HTTP/SOCKS proxy configuration for outbound requests. Supports three modes: Off (never use proxy), System (auto-detect from environment/system settings), Manual (use explicitly configured URLs).",
640+
"properties": {
641+
"Mode": {
642+
"type": "string",
643+
"enum": ["Off", "System", "Manual"],
644+
"default": "System",
645+
"description": "Proxy mode: Off (never use proxy), System (auto-detect from environment variables or WinHTTP), Manual (use configured URLs)"
646+
},
647+
"Http": {
648+
"type": "string",
649+
"description": "HTTP proxy URL for http:// requests (e.g., http://proxy.corp:8080). Only used when Mode is Manual."
650+
},
651+
"Https": {
652+
"type": "string",
653+
"description": "HTTPS proxy URL for https:// requests (e.g., http://proxy.corp:8080). Only used when Mode is Manual."
654+
},
655+
"All": {
656+
"type": "string",
657+
"description": "Fallback proxy URL for all protocols (e.g., socks5://proxy.corp:1080). Only used when Mode is Manual."
658+
},
659+
"Exclude": {
660+
"type": "array",
661+
"items": {
662+
"type": "string"
663+
},
664+
"description": "Bypass list with NO_PROXY semantics. Supports: wildcard '*', exact hostname 'example.com', domain suffix '.corp.local', IP address '127.0.0.1', CIDR range '10.0.0.0/8'. Only used when Mode is Manual."
665+
}
666+
},
667+
"additionalProperties": false
668+
},
633669
"DebugConf": {
634670
"type": "object",
635671
"properties": {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "http-client-proxy"
3+
version = "0.0.0"
4+
edition = "2024"
5+
authors = ["Devolutions Inc. <infos@devolutions.net>"]
6+
publish = false
7+
8+
[lints]
9+
workspace = true
10+
11+
[dependencies]
12+
proxy_cfg = "0.4"
13+
reqwest = { version = "0.12", default-features = false }
14+
anyhow = "1.0"
15+
url = "2.5"
16+
tracing = "0.1"
17+
ipnet = "2.10"
18+
parking_lot = "0.12"
19+
20+
[dev-dependencies]
21+
rstest = "0.25"

0 commit comments

Comments
 (0)