在nginx中禁用请求缓冲

在nginx中禁用请求缓冲

本文介绍了在nginx中禁用请求缓冲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来,nginx在将请求传递给updstream服务器之前缓冲了请求,而对于大多数情况来说这对我来说是非常糟糕的:)



我的情况是像这样︰

我有nginx作为前端服务器来代理3个不同的服务器:
$ b $ ol

  • 具有典型PHP应用程序的apache

  • 由python和gevent构建的shaveet(一个开放源代码的comet服务器)
  • 用gevent重新构建,代理上传到rackspace cloudfiles
    ,同时接受来自客户端的上传。

  • #3是问题,现在我所拥有的是nginx缓冲所有请求,然后将其发送到文件上传服务器,然后将其发送到云文件,而不是发送每个块,因为它得到它(使得上传更快,因为我可以推动6 -7MB / s到cloudfiles)。

    我使用nginx的原因是有一个IP的3个不同的域如果我不能这样做,我将不得不移动文件上传服务器到另一台机器。

    解决方案

    据网站上声明入站请求必须在上传之前被缓存。



    lockquote

    请注意,当使用HTTP代理模块(甚至是使用FastCGI)时,整个客户端请求将在传递到后端之前缓存在nginx中因此,如果上传进度表通过测量后端服务器接收到的数据来工作,则上传进度表将无法正常工作。


    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 have nginx as a frontend server to proxy 3 different servers:

    1. apache with a typical php app
    2. shaveet(a open source comet server) built by me with python and gevent
    3. a file upload server built again with gevent that proxies the uploads to rackspace cloudfileswhile accepting the upload from the client.

    #3 is the problem, right now what I have is that nginx buffers all the request and then sends that to the file upload server which in turn sends it to cloudfiles instead of sending each chunk as it gets it (those making the upload faster as i can push 6-7MB/s to cloudfiles).

    The reason I use nginx is to have 3 different domains with one IP if I can't do that I will have to move the fileupload server to another machine.

    解决方案

    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.

    这篇关于在nginx中禁用请求缓冲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    09-03 07:21