istio:VirtualService重写为根URL [英] istio: VirtualService rewrite to the root url

查看:662
本文介绍了istio:VirtualService重写为根URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Istio 1.4.6 VirtualService,具有一个匹配项和一个如下定义的url重写:

I have an Istio 1.4.6 VirtualService with a match and a url rewrite defined as follows:

    match:
    - authority:
        prefix: example.com
      uri:
        prefix: /foo/bar
    rewrite:
      uri: /
    route:
    - destination:
        host: some-service
        port:
          number: 80

我想要这样的重写:

指向/foo/bar的交通或其任何子路径应重写为/加上some-service上的任何子路径.

Traffic directed to /foo/bar or any subpath of that should be rewritten to / plus any subpath on some-service.

i.e.
example.com/foo/bar -> some-service
example.com/foo/bar/subpath -> some-service/subpath
example.com/foo/bar/subpath/anothersubpath -> some-service/subpath/anothersubpath

但是,当我对进入some-service的流量进行系统分析时,我发现Istio已将路径重写为:

However, when I sysdig the traffic coming into some-service, I see that Istio has rewritten the path to:

GET //subpath/anothersubpath HTTP/1.1

请注意GET请求中的两个斜杠.在VirtualService spec rewrite.uri字段中,我似乎无法将该字段保留为空白或在其中添加空字符串.这样做会导致资源无法验证.

Notice the two slashes in the GET request. In the VirtualService spec rewrite.uri field, I can't seem to leave that field empty or add an empty string there. Doing so causes the resource not to validate.

即我不能这样做:

    rewrite:
      uri: ""

而且不能这样做

    rewrite:
      uri:

如何定义VirtualService重写以将流量发送到目标服务的根目录?任何帮助深表感谢.

How can I define a VirtualService rewrite to send traffic to the root of the destination service? Any help is much appreciated.

推荐答案

有一个github 问题关于此.

There is a github issue about this.

最简单的解决方法是,只要您没有运行.net核心应用程序,就在uri中添加空格.

The simplest fix is to add whitespace in the uri as long as You are not running .net core application.

    rewrite:
      uri: " "

可以在此处

希望有帮助.

这篇关于istio:VirtualService重写为根URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆