Disable proxy buffering for websockets

Maxim Dounin mdounin at mdounin.ru
Mon Dec 17 02:26:40 UTC 2018


Hello!

On Sun, Dec 16, 2018 at 02:45:56PM -0800, Chad Phillips wrote:

> I use software that runs a speed test via websockets. When proxying this
> websocket connection through Nginx, the 'download' portion of the test is
> inaccurate.
> 
> My theory is that this is due to Nginx buffering the response from the
> backend server, thus the timer on the backend server reports an inaccurate
> value compared to when it's not proxied.
> 
> I've tried the following settings at both the location and server levels of
> my configuration:
> 
>     proxy_buffering off;
>     proxy_ignore_headers X-Accel-Buffering;
> 
> However, this doesn't fix the problem. I've confirmed the functionality
> works correctly when it's not being proxied via Nginx, so wondering if A)
> there is some other cause of the issue besides the proxy buffer, or B) I'm
> not using the proxy buffer settings correctly?

As long as a connection is upgraded to the websockets protocol, 
buffering doesn't matter: regardless of the settings nginx will 
proxy anything without buffering.

Note though that websockets proxying requires special 
configuration, see here:

http://nginx.org/en/docs/http/websocket.html

Note well that proxying though nginx implies several additional 
buffers being used anyway (two socket buffers and a proxy buffer 
within nginx), and this may reduce accuracy.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list