413 Request Entity Too Large with the Nginx Ingress controller

July 8, 2019
kubernetes | deployment | ingress

If you’re using the Nginx Ingress Controller on Kubernetes, you might have stumbled on a response code 413 when you upload items via the ingress controller.

According to http.cat, 413 means Payload too large. This is because the default maximum body size in the ingress controller is configured to a rather small default value.

Luckily, there is an annotion you can add to the ingress definition which can change this value. The annotation you need to use is called nginx.ingress.kubernetes.io/proxy-body-size.

You can configure it as follows:

apiVersion: extensions/v1beta1
kind: Ingress
    nginx.ingress.kubernetes.io/proxy-body-size: "0"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "600"
    kubernetes.io/tls-acme: 'true'
  name: docker-registry
  namespace: docker-registry
  - hosts:
    - registry.<your domain>
    secretName: registry-tls
  - host: registry.<your domain>
      - backend:
          serviceName: docker-registry
          servicePort: 5000
        path: /

There are many more annotations you can use. You can find the full list here.