0

I have a working Envoy proxy configuration that matches two routes /name/foo/bar?mode=receive-data and /name/receive-data. The Envoy configuration file looks something like this:

static_resources:
  ...
    filter_chains:
    - filters:
      - name: envoy.http_connection_manager
        typed_config:
          ...
          route_config:
            virtual_hosts:
            - ...
              routes:
              - match:
                  prefix: "/name/foo/bar?mode=receive-data"
                ...
              - match:
                  prefix: "/name/receive-data"
                ...

I need to update the configuration from using route prefix matching to regex match as explained in the route.RouteMatch documentation. These two route deinitions must be converted to /:name/foo/bar?mode=receive-data and /:name/receive-data somehow, where :name can be [a-z0-9]. I've tried to write my own regex: for this, but with no success, so I'd appreciate some help here.

xpepermint
  • 267
  • 3
  • 9

2 Answers2

0

To find location matching a given request, nginx first checks locations defined using the prefix strings (prefix locations).

Wed
  • 15
  • 9
0

According to documentation on 1.13.1:

- match:
   safe_regex:
    google_re2: {}
    regex: "\/.*\/foo\/bar"
  route:
    cluster: whatever
- match:
    safe_regex:
      google_re2: {}
      regex: "\/.*\/receive-data"
  route:
    cluster: somethingelse
Jonke
  • 101
  • 2
  • Could the first regex potentially match `/something/foo/barS` or `/something/foo/bar/more` ? – jakubiszon Jan 14 '21 at 11:49
  • See https://github.com/envoyproxy/envoy/blob/main/test/tools/router_check/test/config/TestRoutes.yaml#L136 for more regex match examples including matching on :path – Greg Bray Mar 27 '21 at 14:30