上传大文件nginx报413 Request Entity To
2019-12-04 本文已影响0人
每天进步一典
image.png
先说明一下请求的流程
报错的是程序客户端上传不了大视频(10m以上)到微服务的应用里边
请求流程如下
客户端------》外网nginx入口------》k8s的nginx ingress-----》java微服务应用
开始以为是外网的nginx服务器限定了文件上传的大小,设置了外网nginx的client_max_body_size=100m (上传最大为100m)发现怎么重启还是报同样的错误
于是便怀疑是nginx ingress的问题,里面的nginx ingress controler也有一段代理到backend的默认nginx配置
于是改了配置nginx ingress的configmap 的 client-body-size 为100m
[lishiwei@test-k8s-01 nginx-ingress]$ cat 01-configmap.yaml
---
# https://github.com/nginxinc/kubernetes-ingress/tree/master/examples/customization
kind: ConfigMap
apiVersion: v1
metadata:
name: nginx-ingress-configuration
namespace: kube-system
labels:
k8s-app: nginx-ingress
data:
client-max-body-size: "100m"
proxy-body-size: "100m"
---
kind: ConfigMap
apiVersion: v1
metadata:
name: nginx-ingress-tcp-services
namespace: kube-system
---
kind: ConfigMap
apiVersion: v1
metadata:
name: nginx-ingress-udp-services
namespace: kube-system
然后
[lishiwei@test-k8s-01 nginx-ingress]$ kubectl apply -f 01-configmap.yaml
configmap "nginx-ingress-configuration" configured
configmap "nginx-ingress-tcp-services" unchanged
configmap "nginx-ingress-udp-services" unchanged
就可以上传成功了
image.png