disable request buffering in nginx

前端 未结 4 534
滥情空心
滥情空心 2021-02-03 12:34

It seems that nginx buffers requests before passing it to the updstream server,while it is OK for most cases for me it is very bad :)

My case is like this:

I hav

相关标签:
4条回答
  • 2021-02-03 13:22

    I'd look into haproxy to fulfill this need.

    0 讨论(0)
  • 2021-02-03 13:24

    As soon as this [1] feature is implemented, Nginx is able to act as reverse proxy without buffering for uploads (bug client requests). It should land in 1.7 which is the current mainline.

    [1] http://trac.nginx.org/nginx/ticket/251

    Update

    This feature is available since 1.7.11 via the flag

    proxy_request_buffering on | off;

    http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_request_buffering

    0 讨论(0)
  • 2021-02-03 13:27

    Now available in nginx since version nginx-1.7.11.

    See documentation http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_request_buffering

    To disable buffering the upload specify

    proxy_request_buffering off;
    
    0 讨论(0)
  • 2021-02-03 13:33

    According to Gunicorn, they suggest you use nginx to actually buffer clients and prevent slowloris attacks. So this buffering is likely a good thing. However, I do see an option further down on that link I provided where it talks about removing the proxy buffer, it's not clear if this is within nginx or not, but it looks as though it is. Of course this is under the assumption you have Gunicorn running, which you do not. Perhaps it's still useful to you.

    EDIT: I did some research and that buffer disable in nginx is for outbound, long-polling data. Nginx states on their wiki site that inbound requests have to be buffered before being sent upstream.

    "Note that when using the HTTP Proxy Module (or even when using FastCGI), the entire client request will be buffered in nginx before being passed on to the backend proxied servers. As a result, upload progress meters will not function correctly if they work by measuring the data received by the backend servers."

    0 讨论(0)
提交回复
热议问题