I was waiting on the Regex Rewrite based on Capture Groups for a long time and it was finally merged in 1.19.4. I cannot find much documentation regarding how to use the uriRegexRewrite and my attempts to make it work all failed so far.
I need the VirtualService to capture something like /captcha-srv(/|$)(.*) and rewrite it to /$2
My current Virtual Service looks like this:
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
labels:
app.kubernetes.io/instance: authserver-webapi
name: authserver-webapi
namespace: istio-full
spec:
gateways:
- authserver-webapi
hosts:
- auth.example.com
http:
- match:
- uri:
regex: /captcha-srv(/|$)(.*)
rewrite:
uri: /
route:
- destination:
host: captcha
port:
number: 80
- route:
- destination:
host: authserver-webapi
port:
number: 80
This setup rewrites whatever you write after captcha-srv to my microservice's / however, I need it to send /captcha-srv to / and e.g. /captcha-srv/v1 to /v1. In Nginx Ingress, this is easily done, but apparently, this feature was recently added to Istio, and using the documentation wasn't much help except that the directive used to achieve this is uriRegexrewrite.
Any help?