<p>I believe that I must create multiple <code>Ingress</code> resources to achieve the desired effect, but must ask, is it possible to have multiple rewrite annotations with nginx (community) controller for the same host?</p>

<p>I have the following, but it won't work, as I understand it, because there is no way to link the rewrite rule to the path explicitly. In this case, I suppose it could use the fact that there are different numbers of capture groups, but that wouldn't always be the case. </p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: api-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: https://staging.example.com/keyword-lnk/badnewsbears/$1/$2
    nginx.ingress.kubernetes.io/rewrite-target: https://staging.example.com/lnk/$2
    certmanager.k8s.io/cluster-issuer: staging-letsencrypt-prod

spec:
  rules:
    - host: staging.example.com
      http:
        paths:
         - path: /
           backend:
              serviceName: api-service
              servicePort: http
    - host: badnewsbears.example.com
      http:
        paths:
          - backend:
              serviceName: api-service
              servicePort: http
            path: ^(/a/)(.*)$
          - backend:
              serviceName: api-service
              servicePort: http
            path: ^/([tbc])/(.*)
  tls:
  - hosts:
    - staging.example.com
    - badnewsbears.example.com
    secretName: letsencrypt-prod-issuer-account-key
    # ^ must be set to the key matching the annotation
    # certmanager.k8s.io/cluster-issuer above
</code></pre>

<p>The goal is to have requests to <code>staging.example.com</code> not have rewrites, but requests to <code>badnewsbears.example.com/t/soup</code> rewrite to <code>https://staging.example.com/keyword-lnk/badnewsbears/t/soup</code>, while
<code>badnewsbears.example.com/a/soup</code> yields <code>https://staging.example.com/lnk/$2</code></p>

<p>Is there a way to specify a mapping of rewrite target->path in the <code>Ingress</code> (or elsewhere), or will I have to separate out the different rewrite rules for the same host into different </p>

<p>TL;DR; you're not really meant to be able to configure multiple rewrites for the kubernetes/ingress-nginx controller type. Although it is possible to hack this together in a limited fashion using regex based rewrites with capture groups, as explained in this answer I posted to <a href="https://stackoverflow.com/a/57822415/207488">How to proxy_pass with nginx-ingress?
</a>.</p>

<p>Hope this helps.</p>
