默认nginx client_max_body_size

Default nginx client_max_body_size

我一直在收到nginx错误:

1
413 Request Entity Too Large

我已经能够将我的nginx.conf文件的server部分中的client_max_body_size更新为20M,这已解决了该问题。 但是,默认的nginx client_max_body_size是什么?


client_max_body_size指令的默认值为1 MiB。

可以在httpserverlocation上下文中进行设置-在大多数情况下,
嵌套块中的此伪指令优先于祖先块中的同一伪指令。

摘自ngx_http_core_module文档:

1
2
3
Syntax:   client_max_body_size size;
Default:  client_max_body_size 1m;
Context:  http, server, location

Sets the maximum allowed size of the client request body, specified in
the"Content-Length" request header field. If the size in a request
exceeds the configured value, the 413 (Request Entity Too Large) error
is returned to the client. Please be aware that browsers cannot
correctly display this error. Setting size to 0 disables checking of
client request body size.

别忘了重新加载配置
通过nginx -s reloadservice nginx reload命令(以sudo开头)(如果有)。


Pooja Mane的答案对我有用,但是我必须将client_max_body_size变量放在http部分中。

enter image description here


您可以通过以下方式在nginx配置文件中增加主体大小:

sudo nano /etc/nginx/nginx.conf

client_max_body_size 100M;

重新启动nginx以应用更改。

sudo service nginx restart