How do I set the client_max_body_size parameter for a single subdomain? I have a server that will accept file uploads up to 5TB. All the examples I've looked at show you how to set it globally. I have multiple rules in my ingress.yaml, I don't want every single rule to inherit the client_max_body_size parameter, only the file upload server should.
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-nginx
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- host: example.com
http:
paths:
- backend:
serviceName: homepage
servicePort: 80
- host: storage.example.com
http:
paths:
- backend:
serviceName: storage
servicePort: 80
In the above ingress.yaml, I want to set client_max_body_size for the storage service only, which is located at the host storage.example.com.
In more recent versions of ingress-nginx, there is a dedicated annotation for the ingress resource called nginx.ingress.kubernetes.io/proxy-body-size:
metadata:
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: 5tb
If you use the configuration-snippet from this answer, it would currently result in an error like:
[emerg] 551#551: "client_max_body_size" directive is duplicate in /tmp/nginx/nginx-cfg123:321
nginx: [emerg] "client_max_body_size" directive is duplicate in /tmp/nginx/nginx-cfg123:321
nginx: configuration file /tmp/nginx/nginx-cfg123 test failed
Because I don't see client-max-body-size on the list of annotations, that leads me to believe you'll have to use the custom-config-snippet to include the client_max_body_size 5tb; for that Ingress:
metadata:
annotations:
nginx.ingress.kubernetes.io/configuration-snippet: |
client_max_body_size 5tb;
However, given that you said that you only want it for storage.example.com, you'll need to split the Ingress config for storage.example.com out into its own Ingress resource, since (AFAIK) the annotations are applied to every host: record in the Ingress resource.
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