我已经将 nginx 配置为在 gunicorn 下运行的 Python 应用程序的前端,但 nginx 在发送了大约 65k 数据后终止了连接。
例如,我有一个如下所示的视图:
def debug_big_file(request):
return HttpResponse("x" * 500000)
Run Code Online (Sandbox Code Playgroud)
但是当我通过 nginx 访问那个 URL 时,我只得到 65283 个字节:
$ curl https://example.com/debug/big-file | wc
…
curl: (18) transfer closed with outstanding read data remaining
0 1 65283
Run Code Online (Sandbox Code Playgroud)
请注意,直接访问 gunicorn 时一切正常:
$ curl http://localhost:1234/debug/big-file | wc
…
0 1 500000
Run Code Online (Sandbox Code Playgroud)
相关的 nginx 配置:
location / {
proxy_pass http://localhost:1234/;
proxy_redirect off;
proxy_headers_hash_bucket_size 96;
}
Run Code Online (Sandbox Code Playgroud)
和 nginx 版本 1.7.0
其他一些事实:
"x" * 110000
返回所有 110,000 字节),但 120k 字节不是tcpdump
表明 nginx 正在向 gunicorn 发送 RST 数据包: Dav*_*ver 10
好的!仔细检查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"
Run Code Online (Sandbox Code Playgroud)
proxy_temp
目录的权限如何混乱,导致 nginx 无法正确缓冲到它。
归档时间: |
|
查看次数: |
5525 次 |
最近记录: |