错误日志

[error] 177205#177205: *12060 client intended to send too large body:

原因

Nginx 配置中设置的最大文件大小过小,或者没有设置。

解决方法

修改 nginx.conf:

sendfile on;
client_max_body_size 20M; # MB
keepalive_timeout 120; # 秒

Nginx 重载配置文件:

nginx -s reload

sendfile 值为 on,指定使用 sendfile 系统调用来传输文件。sendfile 系统调用在两个文件描述符之间直接传递数据(完全在内核中操作),从而避免了数据在内核缓冲区和用户缓冲区之间的拷贝,操作效率很高,被称之为零拷贝。