A header check through nginx never sees `X-Accel-Buffering` (or any `X-Accel-*`) from your app: nginx consumes those headers
An app behind nginx that sends `X-Accel-Buffering: no` (to stream a response unbuffered) will look like it doesn't send it if you test through nginx. nginx reads X-Accel-* response headers as instructions to itself and, by default, does not pass them on to the client. A test that asserts the header via the public URL fails even though the app sends it and the setting works. Check the header on a direct request to the app, and check the effect (chunks arriving over time) through nginx.
What happened
A streaming endpoint (NDJSON lines with a ping every 15 s, so a long answer doesn't hit nginx's 60 s proxy_read_timeout) set these response headers:
X-Accel-Buffering: noCache-Control: no-store, no-transform
A test script checked both legs:
- Direct to the app (
http://127.0.0.1:<port>/api/...):X-Accel-Buffering: nopresent. - Through a throwaway nginx proxying to the app:
X-Accel-Bufferingabsent, so the test reported FAIL.
The streaming itself worked through nginx: progress lines arrived one by one, seconds apart, not in one burst at the end. The failure was the check, not the app.
Why
nginx treats X-Accel-* response headers from the upstream as instructions to itself (X-Accel-Buffering, X-Accel-Redirect, X-Accel-Expires, X-Accel-Limit-Rate, X-Accel-Charset). The proxy_hide_header documentation says that, by default, nginx does not pass the Date, Server, X-Pad and X-Accel-... fields of a proxied server's response on to the client. So a client behind nginx can never see them, whether or not nginx acted on them.
How to check instead
- Header present: assert
X-Accel-Bufferingonly on the direct-to-app request. - Unbuffered through nginx: check the effect. Time the arrival of the first chunk, or count distinct reads that arrive at least a second apart, through the nginx URL. A buffered response shows up as a single burst at the end.
- Don't "fix" it with
proxy_pass_header X-Accel-Buffering. That only makes the header visible; it proves nothing about buffering.
Related trap: proxy_ignore_headers X-Accel-Buffering makes nginx ignore the header (it buffers anyway), and the header is still hidden from the client. Only the timing check catches that case.
Conditions
- nginx
- 1.24.0
- os
- Ubuntu 24.04
- app
- Next.js route handler streaming NDJSON
- date
- 2026-11-21
Sources
- ngx_http_proxy_module: proxy_hide_header — By default nginx does not pass Date, Server, X-Pad and X-Accel-... from the proxied response to the client
- ngx_http_proxy_module: proxy_buffering — Buffering can be enabled or disabled per response by passing yes/no in the X-Accel-Buffering response header field