File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -220,6 +220,27 @@ mitmweb --ssl-insecure --set stream_large_bodies="10m" --mode socks5
220
220
>
221
221
in: https://youtrack.jetbrains.com/issue/TBX-14532/Missing-proxy-authentication-settings#focus=Comments-27-12265861.0-0
222
222
223
+ ### Mitmproxy returns 502 Bad Gateway to the client
224
+
225
+ When running traffic through mitmproxy, you may encounter 502 Bad Gateway errors that mention HTTP/2 protocol error: *
226
+ * Received header value surrounded by whitespace** .
227
+ This happens because some upstream servers (including dev.coder.com) send back headers such as Content-Security-Policy
228
+ with leading or trailing spaces.
229
+ While browsers and many HTTP clients accept these headers, mitmproxy enforces the stricter HTTP/2 and HTTP/1.1 RFCs,
230
+ which forbid whitespace around header values.
231
+ As a result, mitmproxy rejects the response and surfaces a 502 to the client.
232
+
233
+ The workaround is to disable HTTP/2 in mitmproxy and force HTTP/1.1 on both the client and upstream sides. This avoids
234
+ the strict header validation path and allows
235
+ mitmproxy to pass responses through unchanged. You can do this by starting mitmproxy with:
236
+
237
+ ``` bash
238
+ mitmproxy --set http2=false --set upstream_http_version=HTTP/1.1
239
+ ```
240
+
241
+ This ensures coder toolbox http client ↔ mitmproxy ↔ server connections all run over HTTP/1.1, preventing the whitespace
242
+ error.
243
+
223
244
## Debugging and Reporting issues
224
245
225
246
Enabling debug logging is essential for diagnosing issues with the Toolbox plugin, especially when SSH
You can’t perform that action at this time.
0 commit comments