Disabling proxy_buffering not working

Maxim Dounin mdounin at mdounin.ru
Mon May 6 20:05:27 UTC 2019


On Mon, May 06, 2019 at 07:08:44PM +0000, Yuhao Zhang wrote:

> I am facing this issue where proxied server's response is 
> buffered before sending back to the request client, even when 
> proxy_buffering is disabled.
> I also tried setting "X-Accel-Buffering: no" header on the 
> response, but it didn't work.
> I posted the issue on ingress-nginx github repo, since It is 
> what I am using on Kubernetes. However, now I think the root 
> cause is in the underlying nginx. The ingress controller did its 
> job correctly, which is configuring nginx.
> The full story and a reproducible example can be found here: 
> https://github.com/kubernetes/ingress-nginx/issues/4063
> The nginx version used by the controller is 1.15.6

>From the issue description it looks like you think that proxying 
with "proxy_buffering off;" should preserve HTTP transfer encoding 
chunks as received from the upstream server.  It's not, chunk 
boundaries are not guaranteed to be preserved regardless of the 
buffering settings.  Chunked transfer encoding is a property of a 
message as transferred between two HTTP entities, and can be 
modified by any HTTP intermediary.  You should not assume it will 
be preserved.  Quoting RFC 7230:

   Unlike Content-Encoding (Section of [RFC7231]),
   Transfer-Encoding is a property of the message, not of the
   representation, and any recipient along the request/response chain
   MAY decode the received transfer coding(s) or apply additional
   transfer coding(s) to the message body, assuming that corresponding
   changes are made to the Transfer-Encoding field-value.  Additional
   information about the encoding parameters can be provided by other
   header fields not defined by this specification.

The "proxy_bufferring off;" means that nginx won't wait for the 
whole buffer to be filled before it will start sending the 
response to the client.  But as long as nginx have more than one 
chunk received from the backend server, it will decode all the 
chunks and will send them to the client combined.

Maxim Dounin

More information about the nginx mailing list