<p>I'm struggling with a following case. I have one service written in .NET Core with some sort of gateway, and because of that two following GraphQL endpoints are under:</p>
<pre><code>https://my-local-cluster.svc/api/abc/graphql
https://my-local-cluster.svc/api/xyz/graphql
</code></pre>
<p>Right now I'm adding an Ingress to my Kubernetes cluster where I have this service and what I want to achieve is:</p>
<pre><code>https://abc.ingresswebsite.com/graphql &lt;- points to https://mywebsite.com/api/abc/graphql
https://xyz.ingresswebsite.com/graphql &lt;- points to https://mywebsite.com/api/xyz/graphql
</code></pre>
<p>Is that possible? I was trying to do following:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-app-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;true&quot;
    appgw.ingress.kubernetes.io/backend-path-prefix: &quot;/api/abc/&quot;
    cert-manager.io/cluster-issuer: letsencrypt
spec:
  tls:
  - hosts:
    - abc.ingresswebsite.com
    secretName: tls-secret
  rules:
  - host: abc.ingresswebsite.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: my-abc-service
            port: 
              number: 80
</code></pre>
<p>As you can see I used the <code>appgw.ingress.kubernetes.io/backend-path-prefix: &quot;/api/abc/&quot;</code> annotation but unfortunately without any result. Maybe you have a proposition how to achieve that, or if thats even possible to achieve?</p>
<p>Thanks!</p>

Adrian 
<p>Are you trying to make a request for <code>https://abc.ingresswebsite.com/graphql</code> go to <code>/api/abc/graphql</code> on your <code>my-abc-service</code> service?</p>
<p>If so, then perhaps the nginx-ingress' <code>rewrite</code> functionality (<a href="https://kubernetes.github.io/ingress-nginx/examples/rewrite/" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/examples/rewrite/</a>) might work for you.</p>
<p>Here's the example from the documentation:</p>
<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:
  ingressClassName: nginx
  rules:
  - host: rewrite.bar.com
    http:
      paths:
      - path: /something(/|$)(.*)
        pathType: Prefix
        backend:
          service:
            name: http-svc
            port: 
              number: 80
</code></pre>
<p>And here's what the documentation describes as the result of the rewrite:</p>
<blockquote>
<p><code>rewrite.bar.com/something</code> rewrites to <code>rewrite.bar.com/</code></p>
<p><code>rewrite.bar.com/something/</code> rewrites to <code>rewrite.bar.com/</code></p>
<p><code>rewrite.bar.com/something/new</code> rewrites to <code>rewrite.bar.com/new</code></p>
</blockquote>
<p>So adapting that example, your one might look something like this:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-app-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;true&quot;
    nginx.ingress.kubernetes.io/rewrite-target: /api/abc/$1
    cert-manager.io/cluster-issuer: letsencrypt
spec:
  tls:
  - hosts:
    - abc.ingresswebsite.com
    secretName: tls-secret
  rules:
  - host: abc.ingresswebsite.com
    http:
      paths:
      - path: /(.*)
        pathType: Prefix
        backend:
          service:
            name: my-abc-service
            port: 
              number: 80
</code></pre>
<p>(Caveat: I have not tried this)</p>
