<p>I need to define the following routes on my Kubernetes ingress :</p>
<ul>
<li><code>my-website.com/*</code>      =&gt; web client</li>
<li><code>my-website.com/api/*</code>  =&gt; graphql api</li>
</ul>
<p>I've tried to set the following but only the /api route works:</p>
<pre><code>kind: Ingress
metadata:
  name: &quot;my-ingress&quot;
  annotations:
    &quot;kubernetes.io/ingress.class&quot;: nginx
    &quot;nginx.ingress.kubernetes.io/affinity&quot;: cookie
    &quot;nginx.ingress.kubernetes.io/rewrite-target&quot;: &quot;/$2&quot;
    &quot;nginx.ingress.kubernetes.io/use-regex&quot;: &quot;true&quot;
  spec:
    rules:
      - host: my-website.com
        http:
          paths:
            - path: &quot;/api(/|$)(.*)&quot;
              backend:
                serviceName: web-client
                servicePort: 80
            - path: &quot;/&quot;
              backend:
                serviceName: graphql-server
                servicePort: 80
</code></pre>
<p>What's the problem with the <code>/</code> route?</p>
<p><em>I've tried to use <code>/</code> and <code>/(.*)</code> paths but none redirects to the correct service.</em></p>

bbenoist
<p>Could you after replace <code>&quot;nginx.ingress.kubernetes.io/rewrite-target&quot;: &quot;/$2&quot;</code> to <code>&quot;nginx.ingress.kubernetes.io/rewrite-target: /&quot;</code></p>
<p>Also change path from <code>/api(/|$)(.*)</code> to <code>/api/(.*)</code></p>
<p>I am assuming web-client and graphql-server services are running fine.</p>
<p>in case you still face the issue, please share your ingress controller logs for more details</p>
