1. 程式人生 > 其它 >kubesphere 中 Ingress 域名方式導致413 Request Entity Too Large

kubesphere 中 Ingress 域名方式導致413 Request Entity Too Large

k8s叢集中,將圖片或是檔案上傳到檔案伺服器上,請求body的長度大於1M是就會報錯
413 Request Entity Too Large

解決方案

一、在web的nginx.conf中新增

client_body_buffer_size 50m;
client_max_body_size 100m;

二、在ingress中新增 

annotations:
   nginx.ingress.kubernetes.io/proxy-body-size:"50m"

在ingress的annotations下新增相關的引數

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: lys
-router namespace: lys-ns annotations: kubesphere.io/alias-name: lys-router kubesphere.io/creator: admin kubesphere.io/description: 控制檯路由 nginx.ingress.kubernetes.io/proxy-body-size: 102400m nginx.ingress.kubernetes.io/proxy-connect-timeout: '300' nginx.ingress.kubernetes.io/proxy-read-timeout: '
300' nginx.ingress.kubernetes.io/proxy-send-timeout: '300' spec: tls: - hosts: - nginx.lys.com secretName: my-crt-secret rules: - host: cv.sugon.tech http: paths: - path: / pathType: ImplementationSpecific backend: serviceName: web
-main servicePort: 80

在kubesphere中的路徑為:

專案---》應用負載----》應用路由:

參考:

https://cloud.tencent.com/developer/article/1586810

https://blog.pragtechnologies.com/file-upload-limit-in-kubernetes/