<p>I have the following ingress controller and the host that contains <code>api</code> answers to this url <code>https://api.example.com/docs</code>.</p>

<p>Now I would like to configure this nginx ingress access the <code>/docs</code> endpoint using <code>https://docs.example.com</code>. I have tried to use the annotation rewrite-target but I can't figure out how to accomplish this.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: api-ingress
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    kubernetes.io/ingress.class: nginx
    certmanager.k8s.io/acme-challenge-type: dns01
    certmanager.k8s.io/cluster-issuer: letsencrypt
spec:
  rules:
    - host: example.com
      http:
        paths:
          - path: /
            backend:
              serviceName: web-service
              servicePort: 80
    - host: api.example.com
      http:
        paths:
          - path: /
            backend:
              serviceName: api-service
              servicePort: 80
  tls:
  - hosts:
    - example.com
    secretName: example.com
</code></pre>

marcus
<p>What you need here is the <a href="https://kubernetes.github.io/ingress-nginx/examples/rewrite/#app-root" rel="nofollow noreferrer">app-root annotation</a>. If you use something like this:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
    annotations:
        nginx.ingress.kubernetes.io/app-root: /docs
</code></pre>

<p>incoming requests at <code>example.com/</code> will be rewritten internally to <code>example.com/docs</code>.</p>

<p>Please let me know if that helped.</p>
