Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes nginx ingress controller cannot upload size more than 1mb

I am fairly new to GCP and I have a rest URI to upload large files.
I have a ngress-nginx-controller service and want to change it to upload files larger than 1mb and set a limit.

apiVersion: v1
kind: Service
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app.kubernetes.io/component":"controller","app.kubernetes.io/instance":"ingress-nginx","app.kubernetes.io/managed-by":"Helm","app.kubernetes.io/name":"ingress-nginx","app.kubernetes.io/version":"0.35.0","helm.sh/chart":"ingress-nginx-2.13.0"},"name":"ingress-nginx-controller","namespace":"ingress-nginx"},"spec":{"externalTrafficPolicy":"Local","ports":[{"name":"http","port":80,"protocol":"TCP","targetPort":"http"},{"name":"https","port":443,"protocol":"TCP","targetPort":"https"}],"selector":{"app.kubernetes.io/component":"controller","app.kubernetes.io/instance":"ingress-nginx","app.kubernetes.io/name":"ingress-nginx"},"type":"LoadBalancer"}}
  creationTimestamp: "2020-09-21T18:37:27Z"
  finalizers:
  - service.kubernetes.io/load-balancer-cleanup
  labels:
    app.kubernetes.io/component: controller
    app.kubernetes.io/instance: ingress-nginx
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/version: 0.35.0
    helm.sh/chart: ingress-nginx-2.13.0
  name: ingress-nginx-controller
  namespace: ingress-nginx

This is the error it throws :

<html>
<head><title>413 Request Entity Too Large</title></head>
<body>
<center><h1>413 Request Entity Too Large</h1></center>
<hr><center>nginx/1.19.2</center>
</body>
</html>
like image 846
Jae Avatar asked Dec 05 '25 14:12

Jae


2 Answers

If you need to increase the body size of files you upload via the ingress controller, you need to add an annotation to your ingress resource:

nginx.ingress.kubernetes.io/proxy-body-size: 8m

Documentation available here: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#custom-max-body-size

like image 58
Blender Fox Avatar answered Dec 08 '25 06:12

Blender Fox


If you're using ingress-nginx helm chart

you need to set the values in the following way

controller:
 replicaCount: 2
 service:
 annotations:
  ...
 config:
   proxy-body-size: "8m"
like image 45
Manza Avatar answered Dec 08 '25 07:12

Manza



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!