Istio VirtualService 重写前缀就像完全匹配一样工作

Istio VirtualService rewrite prefix works like exact match

我正在使用 istio 和 运行 路径“/”和“/app”上的服务,“/”和“/app”都将提供相同的页面。为此,我在“/app”上添加了重写规则到“/”,它工作正常。

但是当我尝试点击“/app/login”时,重写不提供页面“/login”。

    - match:
      - uri:
          prefix: /app
      rewrite:
        uri: /
      route:
      - destination:
          host: app-svc
          port:
            number: 8000

这个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: "/"