Default nginx client_max_body_size

2019-02-16 04:04发布

I have been getting the nginx error:

413 Request Entity Too Large

I have been able to update my client_max_body_size in the server section of my nginx.conf file to 20M and this has fixed the issue. However, what is the default nginx client_max_body_size?

标签: nginx
3条回答
够拽才男人
2楼-- · 2019-02-16 04:15

The default value for client_max_body_size directive is 1 MiB.

It can be set in http, server and location context — as in the most cases, this directive in a nested block takes precedence over the same directive in the ancestors blocks.

Excerpt from the ngx_http_core_module documentation:

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.

Don't forget to reload configuration by nginx -s reload or service nginx reload commands prepending with sudo (if any).

查看更多
我只想做你的唯一
3楼-- · 2019-02-16 04:29

Pooja Mane's answer worked for me, but I had to put the client_max_body_size variable inside of http section.

enter image description here

查看更多
Melony?
4楼-- · 2019-02-16 04:31

You can increase body size in nginx configuration file as

sudo nano /etc/nginx/nginx.conf

client_max_body_size 100M;

Restart nginx to apply the changes.

sudo service nginx restart

查看更多
登录 后发表回答