Nginx HTTP 413 Request Entity Too Large

nginx做代理上传文件时返回HTTP 413错误码,提示信息如下:

413 Request Entity Too Large

The requested resource does not allow request data with the requested method or the amount of data provided in the request exceeds the capacity limit. Sorry for the inconvenience.
Please report this message and include the following information to us.
Thank you very much!

这是client_max_body_size没有配置导致的,该参数文档如下:

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 it exceeds the configured value, the client error 413 (Request Entity Too Large) is returned. Please be aware that browsers cannot correctly display this error. Setting size to 0 disables client request body size checking.

可见默认情况下最大只允许上传1M的文件,把这个值调大些就可以了。一般情况下,在http下配置就可以了。但是如果你的nginx代理了多个应用,可能就要对每个应用做不同配置了,这时可以在server和location下配置。

经测试发现:upstream类型为unix socket时在location下配置client_max_body_size是无效的(tengine 1.4.2-1.5.2)。

转载于:https://my.oschina.net/tsl0922/blog/104861

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值