Search code examples
kubernetesnginxkubernetes-ingressnginx-ingressingress-controller

413 error with Kubernetes and Nginx ingress controller


I'm trying to change the client_max_body_size value, so my NGINX ingress will not return the HTTP 413 Content Too Large error (as seen in the logs).

I've tested a few solutions.
Here is my config map:

kind: ConfigMap
apiVersion: v1
data:
  proxy-connect-timeout: "15"
  proxy-read-timeout: "600"
  proxy-send-timeout: "600"
  proxy-body-size: "8m"
  hsts-include-subdomains: "false"
  body-size: "64m"
  server-name-hash-bucket-size: "256"
  client-max-body-size: "50m"
metadata:
  name: nginx-configuration
  namespace: ingress-nginx
  labels:
    app: ingress-nginx

These changes had no effect at all: in NGINX controller's log I can see the information about reloading the config map, but the values in nginx.conf are the same:

$ cat /etc/nginx/nginx.conf | grep client_max                                                                                                       
                            client_max_body_size                    "8m";
                            client_max_body_size                    "1m";
                            client_max_body_size                    "1m";
                            client_max_body_size                    "1m";
                            client_max_body_size                    "1m";
                            client_max_body_size                    "1m";
                            client_max_body_size                    "1m";
                            client_max_body_size                    "1m";
                            client_max_body_size                    "1m";
                            client_max_body_size                    "1m";
                            client_max_body_size                    "1m";
                            client_max_body_size                    "1m";
                            client_max_body_size                    "1m";

My nginx-controller config uses this image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.13.0

How can I force NGINX to change this setting? I need to change it globally, for all my ingresses.


Solution

  • You can use the annotation nginx.ingress.kubernetes.io/proxy-body-size to set the max-body-size option right in your Ingress object instead of changing a base ConfigMap.

    Here is the example of usage:

    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      name: my-app
      annotations:
        nginx.ingress.kubernetes.io/proxy-body-size: "50m"
    ...