<p>I've read the docs a thousand times but I still don't understand how I would use the <code>nginx.ingress.kubernetes.io/app-root</code> annotation.</p>
<p>Can someone please provide an example + description in plain english?</p>
<p>Docs: <a href="https://kubernetes.github.io/ingress-nginx/examples/rewrite/" rel="noreferrer">https://kubernetes.github.io/ingress-nginx/examples/rewrite/</a></p>
<p>I might as well copy paste the entire text; it's not that much.</p>
<blockquote>
<p>nginx.ingress.kubernetes.io/app-root  Defines the Application Root that
the Controller must redirect if it's in '/' context   string</p>
</blockquote>
<p><strong>App Root</strong></p>
<p>Create an Ingress rule with a app-root annotation:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/app-root: /app1
  name: approot
  namespace: default
spec:
  rules:
  - host: approot.bar.com
    http:
      paths:
      - backend:
          serviceName: http-svc
          servicePort: 80
        path: /
</code></pre>
<p>Check the rewrite is working</p>
<pre><code>$ curl -I -k http://approot.bar.com/
HTTP/1.1 302 Moved Temporarily
Server: nginx/1.11.10
Date: Mon, 13 Mar 2017 14:57:15 GMT
Content-Type: text/html
Content-Length: 162
Location: http://stickyingress.example.com/app1
Connection: keep-alive
</code></pre>

<p>It simply <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#rewrite" rel="noreferrer">redirects requests coming to <code>'/'</code> to a different path</a> internally. This is useful if your application's root path is different from <code>'/'</code>.</p>
<p>For example, say your application is listening in <code>'/server'</code>, you'd set your Nginx annotiations like:</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
    annotations:
        nginx.ingress.kubernetes.io/app-root: /server
</code></pre>
<p>At this point, any incoming requests at <code>example.com/</code> would be <a href="https://stackoverflow.com/a/64754302/10892354">redirected with HTTP status code 302</a> to indicate where the resource is: <code>example.com/server</code>.</p>
