<p>I'm setting up an Istio service mesh with two services inside both running a Graphql engine. I'm planning to set them on two different subpaths. How would you set up redirection on VirtualService?</p>

<p>I already tried using this VirtualService config</p>

<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: hasura-1
spec:
  hosts:
  - "*"
  gateways:
  - hasura-gateway
  http:
  - match:
    - uri:
        prefix: /hasura1
    route:
    - destination:
        host: hasura-1
        port:
          number: 80
  - match:
    - uri:
        prefix: /hasura2
    route:
    - destination:
        host: hasura-2
        port:
          number: 80
</code></pre>

<p>but I keep on having error 404 whenever I try accessing these prefixes.</p>

<p><strong>EDIT:</strong> I've updated my virtual service to incorporate <strong><code>rewrite.uri</code></strong>. Whenever I try accessing either prefixes I get redirected to <code>/</code> and it gives out an error 404. Here is my updated Gateway and VirtualService manifest.</p>

<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: hasura-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: hasura-1
spec:
  hosts:
  - "*"
  gateways:
  - hasura-gateway
  http:
  - match:
    - uri:
        exact: /hasura1
    rewrite:
      uri: /
    route:
    - destination:
        host: hasura-1
        port:
          number: 80
  - match:
    - uri:
        exact: /hasura2
    rewrite:
      uri: /
    route:
    - destination:
        host: hasura-2
        port:
          number: 80
---
</code></pre>

<p>On what path your Hasura's GraphQL endpoint is configured?</p>

<p>The way your <code>VirtualService</code> is configured, a request to your gateway will behave like this:</p>

<p><code>my.host.com/hasura1</code> --> <code>hasura-1/hasura1</code><br>
<code>my.host.com/hasura1/anotherpath</code> --> <code>hasura-1/hasura1/anotherpath</code><br>
<code>my.host.com/hasura2</code> --> <code>hasura-2/hasura2</code></p>

<p><strong>Maybe you are missing a <code>rewrite.uri</code> rule to strip the path from the request.</strong></p>

<p>e.g.: With this rule:</p>

<pre><code>http:
- match:
  - uri:
      prefix: /hasura1
  rewrite:
    uri: /
  route:
  - destination:
      host: hasura-1
      port:
        number: 80
</code></pre>

<p>your Hasura container should receive the requests on the root path:</p>

<p><code>my.host.com/hasura1</code> --> <code>hasura-1/</code><br>
<code>my.host.com/hasura1/anotherpath</code> --> <code>hasura-1/anotherpath</code></p>
