I need the URI of requests that reach my myapp
pods to be rewritten to remove the prefix /foo
from the path. For example, a URI /foo/bar
should be received as /bar
. I am using a GCP load balancer that routes traffic directly to pods. I am not using Istio ingress, so Istio has no control over the load balancer's behavior.
I tried creating a VirtualService
to handle the path rewrite:
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: myapp-route
spec:
hosts:
- myapp
http:
- match:
- uri:
prefix: "/foo/"
rewrite:
uri: "/"
route:
- destination:
host: myapp
(This may not be exactly correct as I adapted/simplified what I tried for the question.)
This works when sending requests from a pod with an Istio sidecar to the myapp
service, but not from the load balancer. I can see the URI is being rewritten as it goes out from any other pod, not when it's coming into a myapp
pod.
How can I get URI rewriting as an incoming rule?