第七章 HTTP流量管理(二) URL 重写

URL 重定向功能

浏览器中输入  http://<host_name>:31380/v1/service-A/XXXX

经过下面的重定向,实际调用的是serviceA的/v1/XXXX接口。

浏览器中输入  http://<host_name>:31380/v1/service-B/XXXX

经过下面的重定向,实际调用的是serviceB的/v1/XXXX接口。

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: galaxyvs
spec:
  hosts:
  - "*"
  gateways:
  - galaxygateway
  http:
  - match:
    - uri:
        prefix: /v1/service-A/
    rewrite:
      uri: /v1/
    route:
    - destination:
        host: serviceA.forecasting-platform-dev.svc.cluster.local
        
  - match:
    - uri:
        prefix: /v1/service-B/
    rewrite:
      uri: /v1/
    route:
    - destination:
        host: serviceB.forecasting-platform-dev.svc.cluster.local
原文地址:https://www.cnblogs.com/liufei1983/p/10447264.html