<p>I found a way to do this and side-stepped all that I posed above.</p>
<p>I added the following entry in the <strong>ConfigMap</strong> in <strong>AKS</strong> for my <strong>nginx-ingress</strong> controllers:</p>
<pre><code>data:
  client-max-body-size: 40m
</code></pre>
<p>My pods inherited this (after delete) and applied it to all the server entries in my <strong>default.conf</strong>.  I'll circle back at some point and figure out how to target a specific server entry.</p>

CC BY-SA 4.0
2023-09-27T20:25:47.310Z
2023-09-27T20:25:47.310Z
Conan Stuart
<p>TLDR: Can I utilize my existing deployment YAML (see <strong>dev-deployment.yaml</strong> snippet below) to specify a client_max_body_size to a server or servers in my <strong>nginx ingress</strong>?</p>
<p>Some background:</p>
<ul>
<li>I recently added some functionality to an API for uploading images</li>
<li>Receive this error when attempting uploads in our DEV environment: 413 Request Entity Too Large
<ul>
<li>issue not occurring when running locally</li>
</ul>
</li>
<li>Preliminary research suggested increasing the <strong>nginx</strong> 'client_max_body_size' greater than the attempted upload size</li>
<li>Additionally found that setting an annotation like 'nginx.ingress.kubernetes.io/proxy-body-size' in my YAML might achieve the same goal</li>
<li>This all runs in Azure Kubernetes Service (AKS)</li>
</ul>
<p>I don't know if it's even possible to configure this setting via this method with the desired outcome at this point.  Just seeing if anyone may have a similar configuration and if they were able to resolve it from a YAML perspective, versus going in and editing <strong>nginx</strong> .conf file(s) in the node agents in AKS.</p>
<p><strong>dev-deployment.yaml (ingress rules section only)</strong></p>
<pre><code>#ingress rules
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: someApp-ingress-dev
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/proxy-body-size: 50m
spec:
  tls:
  - hosts:
    - ui-dev.example.com
    - api1-dev.example.com
    - api2-dev.example.com
    - api3-dev.example.com
    - api4-dev.example.com
    secretName: someApp-secret
  rules:
  - host: ui-dev.example.com
    http:
      paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: someApp-ui-dev
              port:
                number: 80
  - host: structures-dev.example.com
    http:
      paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: someApp-api1-api-dev
              port:
                number: 80

// limited to (2) rules for brevity 
</code></pre>

<kubernetes><azure-devops><nginx><yaml>
Increase NGINX Client_Max_Body_Size via YAML (AKS)
Conan Stuart
# Increase NGINX Client_Max_Body_Size via YAML (AKS)

(Asked by: username_0 on 2023-09-27)

TLDR: Can I utilize my existing deployment YAML (see dev-deployment.yaml snippet below) to specify a client_max_body_size to a server or servers in my nginx ingress?
Some background:

I recently added some functionality to an API for uploading images
Receive this error when attempting uploads in our DEV environment: 413 Request Entity Too Large

issue not occurring when running locally


Preliminary research suggested increasing the nginx 'client_max_body_size' greater than the attempted upload size
Additionally found that setting an annotation like 'nginx.ingress.kubernetes.io/proxy-body-size' in my YAML might achieve the same goal
This all runs in Azure Kubernetes Service (AKS)

I don't know if it's even possible to configure this setting via this method with the desired outcome at this point.  Just seeing if anyone may have a similar configuration and if they were able to resolve it from a YAML perspective, versus going in and editing nginx .conf file(s) in the node agents in AKS.
dev-deployment.yaml (ingress rules section only)
#ingress rules
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: someApp-ingress-dev
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/proxy-body-size: 50m
spec:
  tls:
  - hosts:
    - ui-dev.example.com
    - api1-dev.example.com
    - api2-dev.example.com
    - api3-dev.example.com
    - api4-dev.example.com
    secretName: someApp-secret
  rules:
  - host: ui-dev.example.com
    http:
      paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: someApp-ui-dev
              port:
                number: 80
  - host: structures-dev.example.com
    http:
      paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: someApp-api1-api-dev
              port:
                number: 80

// limited to (2) rules for brevity

**Tags:** kubernetes, azure-devops, nginx, yaml


---

## 1 answers

### Answer by username_0 on 2023-09-27. Score: 0

I found a way to do this and side-stepped all that I posed above.
I added the following entry in the ConfigMap in AKS for my nginx-ingress controllers:
data:
  client-max-body-size: 40m

My pods inherited this (after delete) and applied it to all the server entries in my default.conf.  I'll circle back at some point and figure out how to target a specific server entry.


---

