Nginx 文件上传 413 错误 记录
2017-01-17 14:23
351 查看
服务器异常代码413问题
近日与IOS,Android测试多文件上传时偶遇一个413请求实体过大异常。于是乎就开始解决这个问题.首先,项目采用的是Spring +Spring MVC+MyBatis为整体开发框架,所以最先想到的就是mvc-servlet.xml中是否做了设置。
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="maxUploadSize" value="40960000" /> </bean>
明明已经做了文件上传大小限制。怎么还会报请求实体内容过大呢。百思不得其解。就说前台是不是传的文件太大了。所以将maxUploadSize的值调到了100G,发现还是一样的问题。这就不好玩了。思前想后最后才想起来项目中采用了Nginx做负载均衡服务器,是不是Nginx中做了限制 。就上网去查询资料。从Nginx官网中可以看到这样 一句话Nginx_Http_core_module
> 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.
其大致意思是说,规定请求头的”Content-Length” 字段可以限制客户端允许请求实体的大小。如果实际请求实体大小超过所配置的值,将会返回 一个413错误给客户端(请求实体太大)。注意,浏览器不能正确的显示这个错误。设置值为0就意味着不检查客户端请求实体大小。
之后,官网又给出了配置Demo
Syntax: client_max_body_size size; Default: client_max_body_size 1m; Context: http, server, location
配置语法就是client_max_body_size 允许上传文件的大小将其放在 http{}块中。保存之后重启nginx服务器即可解决此问题。
相关文章推荐
- Nginx 413错误的排查:修改上传文件大小限制
- nginx上传文件413错误解决办法
- 关于thinkphp在nginx下上传文件太大显示413错误的解决方法
- nginx 上传文件大小受限 413 错误
- 解决上传文件时 nginx 413 Request Entity Too Large 错误
- nginx:413 Request Entity Too Large 及 修改 PHP上传文件大小配置
- 20100923 学习记录:上传文件错误 Error:‘ASP 0104 : 80004005’
- 修改nginx文件上传大小限制(413 Request Entity Too Large错误解决)
- Nginx 413 修改上传文件大小限制
- Nginx 报错413 Request Entity Too Large 上传文件过大
- Nginx下上传文件http报错413解决方法
- nginx 服务器在上传文件出现413代码的解决方法
- Nginx 413 修改上传文件大小限制
- Nginx 413 修改上传文件大小限制
- 上传文件返回413错误
- nginx:413 Request Entity Too Large 及 修改 PHP上传文件大小配置
- android文件上传413 nginx [error] 9679#0: *318855 client intended to send too large body: 1593409 bytes
- 通过设置nginx的client_max_body_size解决nginx+php上传大文件的问题(报错 http 413 error)
- Nginx上传文件提示413 Request Entity Too Large
- Nginx学习之:上传碰到“413”错误