2

Note: I have a feeling this isn't supported in Istio, but I'm curious if any other reverse-proxy supports this feature besides NGINX?

I am trying to redirect requests from regex: /abc/(?<appname>.*)? to /cba/$appname in a VirtualService within Istio. This seems like a trivial problem granted Istio is supposed to replace NGINX Ingresses, so it seems concerning there isn't much mention of this problem in their docs.

I have found several other posts that refer to similar issues, but I want an explicit answer this is not supported.

I have the following working example that simply redirects the regex /abc/.* to the static address /cba/.

http:
- match:
  - uri:
      regex: /abc/.*?
    ignoreUriCase: true
  rewrite:
    uri: /cba/
- match: 
  - uri: 
      prefix: /
  route: 
  - destination:
      host: service_name

Adding a Capturing Group in the URI regex: /abc/(?<hello>.+)? results in the following error, despite the regex being syntactically correct.

gRPC config for type.googleapis.com/envoy.api.v2.RouteConfiguration rejected: Invalid regex '/abc/(?<hello>.+)?': One of *?+{ was not preceded by a valid regular expression.

Is there something I am missing, or any pointers towards finding a solution to this problem?

Also Note: The documentation for HTTPRewrite states the uri field must be a string, which also makes me worry this feature isn't supported.

I've tried looking through Envoy's documentation and it seems to stem from them not supporting it? Is there any way to extract fields from a regex in any reverse-proxy except NGINX?

Baily
  • 1,290
  • 2
  • 14
  • 35
  • 1
    try to use HA-Proxy. it is more flexible. config [regex example](https://stackoverflow.com/questions/24784517/haproxy-route-and-rewrite-based-on-uri-path). config [reverse proxy example](https://github.com/gnokoheat/ecs-reverse-proxy/blob/master/haproxy.cfg). – GNOKOHEAT Oct 17 '19 at 23:49
  • It looks like [miss-configuration](https://istio.io/docs/reference/config/networking/v1alpha3/virtual-service/#HTTPMatchRequest). If you are using headers in hTTPMatchRequest `The keys uri, scheme, method, and authority will be ignored` Despite of this rewrite/redirect from /abc/(?.*)? to /cba/$appname using regex Capture Group and with prefix substitution [will probably no work](https://github.com/istio/istio/issues/14983). Maybe the solution it could be to provide more rewrite sections like: match: uri: /abc/seach to rewrite: uri:/cba/search etc. in one virtualservice? – Mark Oct 23 '19 at 14:43
  • @Hanx I'm just not sure that's currently supported in Envoy. The PR you sent ends with `it may be worth discussing this over in a GitHub Issue in Envoy.` For now, I'm just going to use NGINX above Istio, changing the ingress-gateway to a cluster IP that gets forwarded to from an NGINX ingress (handling all messy regex rewrites) – Baily Oct 24 '19 at 13:52

0 Answers0