<p>I have a pod that exposes an HTTP service.<br />
This pod has some HTTP endpoints which are available under <code>/accounts</code>.<br />
My goal is to access this sub-path via <code>accounts.example.com</code>.</p>
<p>For example if the url <code>accounts.example.com/test</code> is requested, the nginx ingress should route the request to <code>/accounts/test</code> on my pod.</p>
<p>In the nginx ingress documentation I cannot find a use-case with examples like this.</p>

<p>You should use rewrite to accomplish your request.</p>
<p><a href="https://kubernetes.github.io/ingress-nginx/examples/rewrite/" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/examples/rewrite/</a></p>
<ul>
<li>Here is an example:
<ul>
<li>Focus on this line: <code>path: /something(/|$)(.*)</code></li>
</ul>
</li>
</ul>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  name: rewrite
  namespace: default
spec:
  rules:
  - host: rewrite.bar.com
    http:
      paths:
      - backend:
          serviceName: http-svc
          servicePort: 80
        path: /something(/|$)(.*)
</code></pre>
<hr />
<ul>
<li>Look on the different annotations for the re-write:</li>
</ul>
<p><a href="https://i.stack.imgur.com/hNihu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hNihu.png" alt="enter image description here" /></a>
<a href="https://i.stack.imgur.com/cWtTm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cWtTm.png" alt="enter image description here" /></a></p>
