0

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 

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.