I'm trying to change the client_max_body_size
value, so my nginx ingress will not return 413 error.
I've tested few solutions.
Here is my test 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 has no effect at all, after loading it, in the nginx controller log I can see the information about reloading config map, but the values in nginx.conf are the same:
root@nginx-ingress-controller-95db685f5-b5s6s:/# 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 the nginx to change the value? I need to change it globally, for all my ingresses.
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"
...
To set it globally, this configmap.md documentation might be helpful. Turns out the variable to set is proxy-body-size
, not client-max-body-size
.
When you deploy the helm chart, you can set --set-string controller.config.proxy-body-size="4m"
.
Update:
I have been experiencing the same problem and no solutions were working. After reading through countless blogs and docs that all had the same suggested solution I found that they have changed the naming convention.
It is no longer denoted by "proxy-body-size" or this just never works for me.
link below shows that the correct configmap variable to use is "client-max-body-size"
https://docs.nginx.com/nginx-ingress-controller/configuration/global-configuration/configmap-resource/
Maybe some people got stuck here recently. We just made out that the annotation nginx.ingress.kubernetes.io/proxy-body-size
is not longer being applied and the correct one would be:
annotations:
nginx.org/client-max-body-size: "999m"
Hope this helps to others.
There is confusion here about whether the correct annotation is nginx.ingress.kubernetes.io/proxy-body-size
or nginx.org/client-max-body-size
. The answer is that it might be either!
In the unassailable wisdom of everyone involved, there are two different "NGINX ingresses" in the world. It's hard to tell which you are running, and Google Search is useless at differentiating here (but what's new).
If you are using the official NGINX Ingress, the correct annotation is here: https://docs.nginx.com/nginx-ingress-controller/configuration/ingress-resources/advanced-configuration-with-annotations/
If you are using the official Kubernetes Ingress based on NGINX, the correct annotation is this: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#custom-max-body-size
If the Docker image name of your ingress implementation is k8s.gcr.io/ingress-nginx/controller
then you're using the official Kubernetes version. By elimination, you can determine if you're using the NGINX implementation.
I hope everyone who contributed to this confusing state has a very bad day. The rest of you... stay cheery!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With