一、问题描述
Nginx文件上传报413错误。
二、解决方法
nginx 默认对上传文件的大小做了限制,默认大小为 1m。超过默认大小就会报 413(too large)错误。
解决方法是在 nginx.conf 文件中加入 client_max_body_size,指定限制大小,或设为 0,不做大小检查:
client_max_body_size 100;#指定大小
或
client_max_body_size 0;# 不做大小检查
注意:具体位置在 http 下,否则设置不生效:
http {
include mime.types;
sendfile on;
keepalive_timeout 65;
client_max_body_size 100m;