0
点赞
收藏
分享

微信扫一扫

Nginx常见报错整理【Nginx服务出现413 Request Entity Too Large的解决办法、HTTP请求:Failed to load resource: the server r】

思考的鸿毛 2022-05-09 阅读 90



文章目录

  • ​​前言​​
  • ​​出现问题​​
  • ​​1、Nginx服务出现413 Request Entity Too Large的解决办法​​
  • ​​2、HTTP请求:Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)​​

前言

本篇博客是对Nginx常见报错整理。

所有博客文件目录索引:博客目录索引(持续更新)

出现问题

1、Nginx服务出现413 Request Entity Too Large的解决办法

原因分析

查看Nginx 关于client_max_body_size的描述

http服务客户端最大上传默认设置为1M

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.

解决办法

修改nginx.conf配置文件,增加client_max_body_size大小。

http {
...
# set client body size to 50M #
client_max_body_size 50m;

include /etc/nginx/mime.types;
default_type application/octet-stream;

...
}

2、HTTP请求:Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)

上传文件时出现:请求体过大无法上传

Nginx常见报错整理【Nginx服务出现413 Request Entity Too Large的解决办法、HTTP请求:Failed to load resource: the server r】_服务器

解决方案:设置​​client_max_body_size 8M​

设置位置:

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


我是长路,感谢你的耐心阅读。如有问题请指出,我会积极采纳!
欢迎关注我的公众号【长路Java】,分享Java学习文章及相关资料
Q群:851968786 我们可以一起探讨学习
注明:转载可,需要附带上文章链接




举报

相关推荐

0 条评论