Issue#

Uploading a file or sending a large POST body through a Kubernetes Ingress fails, even though the same request works when sent directly to the pod or service. The client receives:

<html> <head><title>413 Request Entity Too Large</title></head> <body> <center><h1>413 Request Entity Too Large</h1></center> <hr><center>nginx</center> </body> </html>

The ingress-nginx controller logs show:

[error] client intended to send too large body: 15728640 bytes, client: 10.244.0.1, server: app.example.com, request: "POST /upload HTTP/1.1"

Cause#

The ingress-nginx controller sets client_max_body_size to 1m by default. Any request body larger than 1 MiB is rejected by nginx before it reaches your application.

Solution#

  1. Confirm the controller is rejecting the request:
kubectl logs -n ingress-nginx deploy/ingress-nginx-controller | grep "too large body"
  1. Raise the limit for one Ingress with an annotation:
kubectl annotate ingress myapp -n myapp \ nginx.ingress.kubernetes.io/proxy-body-size=50m --overwrite

Or set it in the manifest:

apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: myapp namespace: myapp annotations: nginx.ingress.kubernetes.io/proxy-body-size: "50m" spec: ingressClassName: nginx rules: - host: app.example.com http: paths: - path: / pathType: Prefix backend: service: name: myapp port: number: 80
  1. Or raise the limit for every Ingress by editing the controller ConfigMap:
kubectl patch configmap ingress-nginx-controller -n ingress-nginx \ --type merge -p '{"data":{"proxy-body-size":"50m"}}'

If you installed with Helm, set it in your values so upgrades don't revert it:

helm upgrade ingress-nginx ingress-nginx/ingress-nginx -n ingress-nginx \ --reuse-values --set-string controller.config.proxy-body-size=50m

Tip: A value of 0 disables the size check entirely. Prefer an explicit limit so a single client can't push unbounded bodies through the controller.

  1. If uploads still fail after nginx accepts them, check the application's own limit (for example PHP upload_max_filesize, Spring spring.servlet.multipart.max-file-size, or a framework body parser limit).

Verify#

  • Check that the controller rendered the new value into its config:
kubectl exec -n ingress-nginx deploy/ingress-nginx-controller -- \ grep -n "client_max_body_size" /etc/nginx/nginx.conf
  • Send a test upload larger than 1 MiB and confirm the status code is no longer 413:
head -c 20M /dev/urandom > /tmp/test.bin curl -s -o /dev/null -w "%{http_code}\n" \ -X POST --data-binary @/tmp/test.bin https://app.example.com/upload