URL Istio-VirtualService 抛出 404 的正则表达式匹配
URL Regex match for Istio- VirtualService throwing 404
示例 BookInfo 的我的网关和虚拟服务如下所示:
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
我在网关和 HTTP 路由中终止 TLS,我在“v1”上为 HTTP 配置了正则表达式匹配并将其路由到产品页面服务。
我正在通过向 http://External-IP/api/v1/products
发送请求来对此进行测试(示例应用程序的产品页面服务配置为 return 此端点上的文本正文),但请求失败并返回 HTTP 404。我我不确定我在这里做错了什么,非常感谢任何帮助。
好吧,除非我读错了你的路径过滤器与你的请求不匹配,你的请求是 /api
而你的过滤器没有
我想我在这里发现了错误,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
示例 BookInfo 的我的网关和虚拟服务如下所示:
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
我在网关和 HTTP 路由中终止 TLS,我在“v1”上为 HTTP 配置了正则表达式匹配并将其路由到产品页面服务。
我正在通过向 http://External-IP/api/v1/products
发送请求来对此进行测试(示例应用程序的产品页面服务配置为 return 此端点上的文本正文),但请求失败并返回 HTTP 404。我我不确定我在这里做错了什么,非常感谢任何帮助。
好吧,除非我读错了你的路径过滤器与你的请求不匹配,你的请求是 /api
而你的过滤器没有
我想我在这里发现了错误,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