简体   繁体   English

Nginx 入口错误 413 请求实体太大

[英]Nginx Ingress Error 413 Request Entity Too Large

I use ingress-nginx with Helm Chart.我将 ingress-nginx 与 Helm Chart 一起使用。 I used to have the problem, that when I would upload a file (50MB) that I would get the error 413 Request Entity Too Large nginx.我曾经遇到过这个问题,当我上传一个文件(50MB)时,我会收到错误 413 Request Entity Too Large nginx。

So I changed the proxy-body-size value in my values.yaml file to 150m, so I should now be able to upload my file.所以我将我的 values.yaml 文件中的 proxy-body-size 值更改为 150m,所以我现在应该可以上传我的文件了。 But now I get the error "413 Request Entity Too Large openresty/1.13.6.2".但现在我收到错误“413 Request Entity Too Large openresty/1.13.6.2”。 I checked the nginx.conf file on the ingress controller and the value for client_max_body_size is correctly set to 150m.我检查了入口 controller 上的 nginx.conf 文件,并且 client_max_body_size 的值正确设置为 150m。

After some research I found out that openresty is used by the lua module in nginx.经过一番研究,我发现 nginx 中的 lua 模块使用了 openresty。 Does anybody know how I can set this setting too for openresty, or what parameter I am missing?有谁知道我如何为openresty设置这个设置,或者我缺少什么参数?

My current config is the following:我当前的配置如下:

values.yml:值.yml:

ingress-nginx:
  defaultBackend:
    nodeSelector:
      beta.kubernetes.io/os: linux
  controller:
    replicaCount: 2
    resources:
      requests:
        cpu: 1
        memory: 4Gi
      limits:
        cpu: 2
        memory: 7Gi
    autoscaling:
      enabled: true
      minReplicas: 2
      maxReplicas: 10
      targetCPUUtilizationPercentage: 90
      targetMemoryUtilizationPercentage: 90
    ingressClassResource:
      name: nginx
      controllerValue: "k8s.io/nginx"
    nodeSelector:
      beta.kubernetes.io/os: linux
    admissionWebhooks:
      enabled: false
      patch:
        nodeSelector:
          beta.kubernetes.io/os: linux
    extraArgs:
      ingress-class: "nginx"
    config:
      proxy-buffer-size: "16k"
      proxy-body-size: "150m"
      client-body-buffer-size: "128k"
      large-client-header-buffers: "4 32k"
      ssl-redirect: "false"
      use-forwarded-headers: "true"
      compute-full-forwarded-for: "true"
      use-proxy-protocol: "false"

ingress.yml:入口.yml:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
  namespace: namespacename
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/proxy-buffer-size: "128k"
    nginx.ingress.kubernetes.io/proxy-buffers-number: "8"
    nginx.ingress.kubernetes.io/client-body-buffer-size: "128k"
    nginx.ingress.kubernetes.io/proxy-body-size: "150m"
spec:
  tls:
    - hosts:
        - hostname
  rules:
    - host: hostname
      http:
        paths:
          - path: /assets/static/
            pathType: ImplementationSpecific
            backend:
              service:
                name: servicename
                port:
                  number: 8080

So it turns out the Application wich had the error, had another reverse Proxy infront of it (wich uses Lua and Openresty for oauth registration).所以事实证明应用程序有错误,前面有另一个反向代理(使用 Lua 和 Openresty 进行 oauth 注册)。 The Proxy-body-size attribute needed to be raised there to.需要将 Proxy-body-size 属性提升到那里。 After that the File upload worked之后文件上传工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM