AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 598650
Accepted
David Wolever
David Wolever
Asked: 2014-05-27 10:17:03 +0800 CST2014-05-27 10:17:03 +0800 CST 2014-05-27 10:17:03 +0800 CST

nginx 在 65k 字节后终止连接

  • 772

我已经将 nginx 配置为在 gunicorn 下运行的 Python 应用程序的前端,但是在发送了大约 65k 的数据后,nginx 正在终止连接。

例如,我有一个看起来像这样的视图:

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

相关的 nginx 配置:

location / {
    proxy_pass http://localhost:1234/;
    proxy_redirect off;
    proxy_headers_hash_bucket_size 96;
}

和 nginx 版本 1.7.0

其他一些事实:

  • 每个请求的字节数是一致的,但是根据内容的不同而不同(我第一次注意到它是用一个大的PNG文件,它在65,372字节后被截断,而不是65,283)
  • 110k 字节正确发送(即"x" * 110000返回所有 110,000 字节),但 120k 字节不正确
  • tcpdump表明 nginx 正在向 gunicorn 发送 RST 数据包:nginx 发送 RST
nginx
  • 1 1 个回答
  • 6131 Views

1 个回答

  • Voted
  1. Best Answer
    David Wolever
    2014-05-27T12:56:12+08:002014-05-27T12:56:12+08:00

    好的!在仔细检查了 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 正确缓冲它。

    • 11

相关问题

  • Gzip 与反向代理缓存

  • nginx 作为代理的行为

  • Nginx 学习资源 [关闭]

  • 提供 70,000 个静态文件 (jpg) 的最佳方式?

  • 在 Apache、LightTPD 和 Nginx Web 服务器上提供 PHP 5.x 应用程序的现状?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve