413 Request Entity Too Large
一、背景介绍
在上传图片文件(图片大小 6MB 左右)的时候,接口预览页面报错“413 Request Entity Too Large”,文件上传失败。
二、解决方案
使用的是 Nginx 做的代理,从报错提示可以看出,请求实体过大,Nginx 无法代理转发。
1、修改 Nginx 的配置文件 nginx.conf,在 http 中增加如下内容:
client_max_body_size 20M;
修改后,效果如下:
2、重启 Nginx 服务,命令如下:
systemctl restart nginx
3、再次调用图片上传接口,即可成功调用。