首页 > 解决方案 > 为什么在 nginx 上上传大文件失败?

问题描述

我有一个 140MB 的文件无法在我的 nginx 上上传。

我在nginx.conf“服务器{}”块中设置了以下指令。

        send_timeout 30m;
        proxy_read_timeout 30m;
        client_max_body_size 10g;
        keepalive_timeout 0;
        lingering_timeout 3m;

正在上传较小的文件。当我打开调试日志时,我在最后几条语句中看到了这些行:

[debug] 5291#0: epoll timer: -1
[debug] 4714#0: child: 3 5292 e:0 t:0 d:0 r:1 j:0
[debug] 4714#0: sigsuspend
[debug] 5292#0: epoll: fd:15 ev:0001 d:00007F9F294E72C8
[debug] 5292#0: channel: 32
[debug] 5292#0: channel command: 2
[debug] 5292#0: close channel s:0 pid:4990 our:4990 fd:10
[debug] 5292#0: channel: 32
[debug] 5292#0: channel command: 2
[debug] 5292#0: close channel s:1 pid:4991 our:4991 fd:12
[debug] 5292#0: channel: -2
[debug] 5292#0: timer delta: 141
[debug] 5292#0: worker cycle
[debug] 5292#0: epoll timer: -1
[debug] 5292#0: worker cycle
[debug] 5292#0: epoll timer: -1

标签: nginx

解决方案


修复是设置这个指令:

http2_recv_timeout 3m;

我的客户端连接很慢,这就是文件没有上传到服务器的原因。我正在使用 nginx 版本 1.22.2


推荐阅读