默认 nginx client_max_body_size [英] Default nginx client_max_body_size

查看:62
本文介绍了默认 nginx client_max_body_size的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直收到 nginx 错误:

413 请求实体太大

我已经能够将我的 nginx.conf 文件的服务器部分中的 client_max_body_size 更新为 20M,这已经解决了这个问题.但是,默认的 nginx client_max_body_size 是多少?

解决方案

client_max_body_size 指令的默认值为 1 MiB.

它可以在 httpserverlocation 上下文中设置——如在 大多数情况,此嵌套块中的指令优先于祖先块中的同一指令.

摘自 ngx_http_core_module 文档:

<块引用>

语法:client_max_body_size size;默认值:client_max_body_size 1m;上下文:http、服务器、位置

设置客户端请求正文的最大允许大小,在Content-Length"请求头字段.如果请求中的大小超过配置值,413(请求实体太大)错误返回给客户.请注意浏览器不能正确显示此错误.将 size 设置为 0 将禁用检查客户端请求正文大小.

不要忘记重新加载配置通过 nginx -s reloadservice nginx reload 命令加上 sudo(如果有).

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?

解决方案

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).

这篇关于默认 nginx client_max_body_size的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆