我已经将nginxconfiguration为在gunicorn下运行的Python应用程序的前端,但nginx在大约65k的数据发送之后正在终止连接。
例如,我有一个看起来像这样的视图:
def debug_big_file(request): return HttpResponse("x" * 500000)
但是当我通过nginx访问这个URL时,我只得到了65283个字节:
$ curl https://example.com/debug/big-file | wc … curl: (18) transfer closed with outstanding read data remaining 0 1 65283
请注意,当直接访问gunicorn时,一切都按预期运行:
$ curl http://localhost:1234/debug/big-file | wc … 0 1 500000
相关的nginxconfiguration:
location / { proxy_pass http://localhost:1234/; proxy_redirect off; proxy_headers_hash_bucket_size 96; }
和nginx版本1.7.0
其他一些事实:
"x" * 110000返回全部110,000字节),但是120k字节不正确 tcpdump表明nginx正在向gunicorn发送一个RST数据包: 
好的! 双重检查nginx日志后,原来是这样的问题:
2014/05/26 16:50:56 [crit] 31396#0: *11 open() "…/proxy_temp/2/00/0000000002" failed (13: Permission denied) while reading upstream, client: 1.2.3.4, server: _, request: "GET /debug/big-file HTTP/1.1", upstream: "http://127.0.0.1:1234/debug/big-file", host: "example.com"
一些如何proxy_temp目录的权限搞砸了,这阻止了nginx正确的缓冲。