Istio VirtualService rewrite prefix works like exact match

12/4/2019

I am using istio and running a service on path "/" and "/app" and both "/" and "/app" will serve same page. Achieving this, I have added rewrite rule on "/app" to "/" and it works fine.

But when I am trying to hit "/app/login", rewrite do not serve page "/login".

    - match:
      - uri:
          prefix: /app
      rewrite:
        uri: /
      route:
      - destination:
          host: app-svc
          port:
            number: 8000
-- Ashish Kumar
eks
google-kubernetes-engine
istio
kubernetes

1 Answer

12/4/2019

This github issue discusses this behavior. Your current rule will rewrite /app/login to //login instead of /login. Apparently duplicate slashes are not ignored automatically. The best solution right now is to tweak your rule as mentioned in this comment:

- match:
  - uri:
      prefix: "/app/"
  - uri:
      prefix: "/app"
  rewrite:
    uri: "/"
-- Emil Gi
Source: StackOverflow