Large PUT/POST uploads (>60MB) fail with context canceled when an nginx reverse proxy sits in front of oauth2-proxy. The root cause is that http.Transport inherits Go's default 4KB WriteBufferSize, requiring ~15,000 write syscalls for a 60MB upload. This generates backpressure on the nginx->oauth2-proxy pipe. Once nginx hits proxy_read_timeout between consecutive write ops, it closes the connection, canceling req.Context(), which propagates as context canceled on the in-flight RoundTrip to the upstream. Expose writeBufferSize and readBufferSize on the Upstream config struct, wired to transport.WriteBufferSize and transport.ReadBufferSize in newReverseProxy. Both default to 0 (preserving current behavior, Go uses 4KB). Setting writeBufferSize to 65536 (64KB) reduces write syscalls by 16x and resolves the timeout correlation for large uploads. Fixes #3389 Signed-off-by: Mateen Anjum <mateenali66@gmail.com> |
||
|---|---|---|
| .. | ||
| file.go | ||
| file_test.go | ||
| http.go | ||
| http_test.go | ||
| proxy.go | ||
| proxy_test.go | ||
| rewrite.go | ||
| rewrite_test.go | ||
| static.go | ||
| static_test.go | ||
| upstream_suite_test.go | ||