报错原因:默认情况下,Nginx请求体大小是1M,超过这个限制就会出现413错误
1:服务器部署
可以在Nginx.conf配置中的http节点中设置大小 client_max_body_size 40m,具体大小看公司要求
user root;
worker_processes 1;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/type;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
# 413 Request Entity Too Large
# 默认是1M大小
client_max_body_size 40m;
server {
listen 80;
server_name lis-oms;
location / {
root /usr/html;
index index.html index.htm;
}
}
}
对于服务器部署的项目,配置完就可以了,但是对于容器部署的项目是不行的,还是报413错误
继续排查。。。
2:容器部署
发现报错的413是容器返回的,而不是服务器返的,所以需要(后端或运维)在服务器上改一下负载均衡的配置,这时413的问题就已经解决了
推荐文章:rancher容器部署服务,文件上传413修改nginx无效的解决办法_rancher ingress-nginx 413-CSDN博客