How can I rewrite an URI in a VirtualService but just internally? In other words:
- A client requests api.example.com/users/get/87
- IngressGateway receives the request and translates it to api.example.com/get/87 to the "users" pod. The pod's web server doesn't "know" the URL "api.example.com/users/get/87" but "knows" "api.example.com/get/87"
- To the user's browser, it will still be appearing as "api.example.com/users/get/87" not rewrited.
I need to do it that way because there are several pod/services to respond this same domain "api.example.com"
If write it like this below, it doesn't work because it will cause conflict since I have many pod/services on the same domain:
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: api
namespace: default
spec:
hosts:
- "api.example.com"
gateways:
- istio-system/default-gateway
http:
- match:
- uri:
prefix: /users
rewrite:
uri: "/"
route:
- destination:
host: user
port:
number: 80
- match:
- uri:
prefix: /cars
rewrite:
uri: "/"
route:
- destination:
host: user
port:
number: 80