In HttpRoute resource, use regexMatch captured group in URLRewrite

290 Views Asked by At

I am moving from an nginx ingress controller to a Gateway controller in GKE. In my Ingress resource, I do a URL rewrite using the nginx.ingress.kubernetes.io/rewrite-target annotation. In the rewrite, I use the regex capture group that is outputted from the rules http path.

In the HttpRoute resource, I see ways to do this with a PathPrefix, but I don't see a way to use the regexMatch "output" (captured group) in the rewrite. I only see those 2 options in the rewrite: pathPrefixRewrite and hostRewrite .

Is there a way to have a rewrite based on the regex captured group?

Example: Rewriting /before/(.*)/ending to /after/$1/ending

1

There are 1 best solutions below

1
Yvan G. On

Based from this documentation under limitation and known issue, regular expression is not supported by GKE gateway. However I think you can use Nginx reverse proxy to handle this complex rewriting with regex using the annotation you shared then point it to GKE Gateway as the backend.