URL Regex匹配Istio-VirtualService抛出404



示例BookInfo的My Gateway and VirtualService如下所示:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: bookinfo-gateway
spec:
selector:
istio: ingressgateway # use istio default controller
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
tls:
httpsRedirect: true
- port:
number: 443
name: https
protocol: HTTPS
hosts:
- "*"
tls:
mode: SIMPLE 
serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
privateKey: /etc/istio/ingressgateway-certs/tls.key
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: bookinfo
spec:
hosts:
- "*"
gateways:
- bookinfo-gateway
http:
- match:
- uri:
exact: /productpage
- uri:
prefix: /static
- uri:
exact: /login
- uri:
exact: /logout
route:
- destination:
host: productpage
port:
number: 9080
- match:
- uri:
regex: "v1"
route:
- destination:
host: productpage
port:
number: 9080

我正在网关上终止TLS,在HTTP路由中,我在"上配置了regex匹配;v1";用于HTTP并将其路由到productpage服务。

我通过向http://External-IP/api/v1/products发送一个请求来测试这一点(示例应用程序的productpage服务被配置为在该端点上返回一个文本主体(,但请求以HTTP 404失败。我不确定我在这里做错了什么,任何帮助都将不胜感激。

我想我在这里发现了错误,regex : "v1"不进行部分匹配。

- match:
- uri:
regex: v1
route:
- destination:
host: productpage
port:
number: 9080

相反,我必须指定regex : .*v1.*才能使其工作。我现在可以走路线了。

- match:
- uri:
regex: .*v1.*
route:
- destination:
host: productpage
port:
number: 9080

好吧,除非我读错了,否则你的路径过滤器与你的请求不匹配,你的请求是/api,而你的过滤器没有

最新更新