<p>We are migrating from a traditional nginx deployment to a kubernetes nginx-ingress controller. I'm trying to apply settings at a <code>location</code> level, but can't see how to do so with annotations.</p>

<p>For example, we had:</p>

<pre><code>server {
  listen 80;
  server_name example.com;

  location /allow-big-uploads {
    client_max_body_size 100M;
    ...
  }
}
</code></pre>

<p>And we translate to something like this:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: web-ingress
  annotations:
    nginx.ingress.kubernetes.io/proxy-body-size: 100m &lt;-- this now applies globally
spec:
  rules:
    - host: example.com
      http:
        paths:
          - path: /allow-big-uploads
            backend:
              serviceName: example-svc
              servicePort: 5009
</code></pre>

<p>Adding that annotation under the <code>path</code> section doesn't seem to work. Am I missing something?</p>

Ben T
<p><a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/" rel="nofollow noreferrer">Annotations</a> can only be set on the whole kubernetes resource, as they are part of the resource <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata" rel="nofollow noreferrer">metadata</a>. The <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#ingressspec-v1beta1-networking-k8s-io" rel="nofollow noreferrer">ingress spec</a> doesn't include that functionality at a lower level. </p>

<p>If you are looking for more complex setups, <a href="https://github.com/containous/traefik" rel="nofollow noreferrer">traefik</a> have built a <a href="https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/" rel="nofollow noreferrer">custom resource definition</a> for their ingress controller that allows more configuration per <a href="https://github.com/containous/traefik/blob/cf7f0f878ac1d09338951c0d4461cd5ac4781e72/docs/content/reference/dynamic-configuration/file.yaml#L75" rel="nofollow noreferrer">service</a>. The downside is the definition is not compatible with other ingress controllers.  </p>
