You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(egress): split mitmproxy config into yaml (static) vs env (dynamic)
Move fleet-wide, rarely-changing mitmproxy options into a baked-in
config.yaml under the standard mitm confdir layout, so launch.go only
emits per-deployment dynamic overrides via --set. This eliminates two
classes of bug along the way:
- stream_large_bodies was set in two places (launch.go --set 1m and
custom.py ctx.options 10m), with the addon silently winning — making
the launch.go line dead code. Now declared once in config.yaml (10m).
- ignore_hosts was env-driven with `;`-separated values, but each value
was passed as a separate --set, and mitmproxy --set on a list option
REPLACES the list — so configuring multiple bypass patterns silently
only kept the last one. config.yaml uses a native YAML list with no
override semantics.
Static options now in /var/lib/mitmproxy/.mitmproxy/config.yaml:
mode, listen_host, connection_strategy (eager),
stream_large_bodies (10m), http2, ignore_hosts (empty default),
ssl_verify_upstream_trusted_confdir (default).
Dynamic overrides remain env-driven and applied as --set in launch.go
(precedence: --set > config.yaml > mitm defaults):
OPENSANDBOX_EGRESS_MITMPROXY_TRANSPARENT (toggle)
OPENSANDBOX_EGRESS_MITMPROXY_PORT
OPENSANDBOX_EGRESS_MITMPROXY_SCRIPT
OPENSANDBOX_EGRESS_MITMPROXY_SSL_INSECURE
OPENSANDBOX_EGRESS_MITMPROXY_UPSTREAM_TRUST_DIR
Removed env vars (no internal use, replaced by config.yaml):
OPENSANDBOX_EGRESS_MITMPROXY_CONFDIR — confdir is the mitm user's
home (/var/lib/mitmproxy), which is also where config.yaml lives;
splitting them via env created an unused escape hatch that would
have broken config.yaml discovery.
OPENSANDBOX_EGRESS_MITMPROXY_IGNORE_HOSTS — replaced by ignore_hosts
in config.yaml (native list, no covert-overwrite bug).
The mitmproxy.Config struct loses its ConfDir field accordingly.
SyncRootCA still accepts an optional confDirEnv argument so the existing
candidate-path search behavior is preserved if a future caller needs to
plumb it back in.
|`OPENSANDBOX_EGRESS_MITMPROXY_PORT`| No | mitmdump listen port; `iptables` redirects `80/443` here |`18081`|
46
49
|`OPENSANDBOX_EGRESS_MITMPROXY_SCRIPT`| No | Additional user mitm addon script path (`-s`); loaded after the system addon | Empty |
47
-
|`OPENSANDBOX_EGRESS_MITMPROXY_IGNORE_HOSTS`| No | Host/IP regex list for TLS pass-through (`;` separated) | Empty |
48
-
|`OPENSANDBOX_EGRESS_MITMPROXY_CONFDIR`| No | mitm config and CA directory (passed as `--set confdir=`, also used as `HOME`) | Default directory under `/var/lib/mitmproxy`|
49
-
|`OPENSANDBOX_EGRESS_MITMPROXY_UPSTREAM_TRUST_DIR`| No | Trust directory for upstream TLS verification (OpenSSL style) |`/etc/ssl/certs`|
50
+
|`OPENSANDBOX_EGRESS_MITMPROXY_UPSTREAM_TRUST_DIR`| No | Trust directory for upstream TLS verification (OpenSSL style); overrides the config.yaml default |`/etc/ssl/certs`|
51
+
|`OPENSANDBOX_EGRESS_MITMPROXY_SSL_INSECURE`| No | Skip upstream TLS verification (`1/true/on`); use when clients connect by IP and SNI is unavailable | Disabled |
50
52
51
53
Notes:
52
54
53
-
-`OPENSANDBOX_EGRESS_MITMPROXY_IGNORE_HOSTS` means **no decryption**, not “completely bypass mitm process”.
54
55
- In transparent mode, mitmproxy generally recommends matching by IP/range; verify SNI/resolve behavior if using domain regex only.
55
56
- Before mitm, `iptables`, and CA export are ready, `GET /healthz` returns `503 (mitm not ready)` to prevent premature readiness.
56
57
58
+
### Static Configuration (config.yaml)
59
+
60
+
Fleet-wide, rarely-changing mitm options live in
61
+
`components/egress/mitmproxy/config.yaml`, baked into the image at
62
+
`/var/lib/mitmproxy/.mitmproxy/config.yaml` and auto-loaded by mitmdump.
63
+
This is the single source of truth for:
64
+
65
+
-`mode` (`transparent`)
66
+
-`listen_host` (`127.0.0.1`)
67
+
-`connection_strategy` (`eager`)
68
+
-`stream_large_bodies` (`10m`)
69
+
-`http2` (`true`)
70
+
-`ignore_hosts` (regex list for TLS pass-through; empty by default — append entries here rather than via env, because `--set` on a list option REPLACES the entire list)
71
+
-`ssl_verify_upstream_trusted_confdir` (default `/etc/ssl/certs`; overridable per-deployment via env)
To change a static option for the whole fleet: edit `config.yaml`, rebuild the egress image, redeploy. To bypass decryption for a specific host **temporarily** in one deployment, the option is to edit and remount `config.yaml` rather than pass an env override.
76
+
57
77
## Common Configuration Templates
58
78
59
79
### 1) Enable Transparent MITM Only
@@ -81,11 +101,18 @@ The user addon is loaded after the system addon (`-s system.py -s user.py`), so
81
101
82
102
### 4) Bypass Decryption for Specific Domains (e.g. log upload)
0 commit comments