nginx设置请求body大小

设置如下:

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.

可以选择在http{ }中设置:client_max_body_size 20m;
也可以选择在server{ }中设置:client_max_body_size 20m;
还可以选择在location{ }中设置:client_max_body_size 20m;

三者到区别是:http{} 中控制着所有nginx收到的请求。而报文大小限制设置在server{}中,则控制该server收到的请求报文大小,同理,如果配置在location中,则报文大小限制,只对匹配了location 路由规则的请求生效。

     http{

		#控制全局nginx所有请求报文大小
		#client_max_body_size   20m;

        server{

				#控制该server的所有请求报文大小
				
				#client_max_body_size   20m;

                location a {
                }
                location b{
						#控制满足该路由规则的请求报文大小
						#client_max_body_size   20m;
                }
        }
        
        server {

        }

     }

修改后重启nginx配置生效

转载连接:https://blog.csdn.net/qq459805661/article/details/77723265
nignx官方文档参考:http://www.nginx.cn/doc/standard/httpcore.html

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值