Search code examples
google-cloud-platformyamlload-balancingurl-routingrules

GCP-loadbalancer routing rule with regular expression


actually I am struggling with the routing rules definition for the gcp load-balancer. For my use-case I would need a regular expression so I used a snipped from the examples and tried to adapt it to my needs:

defaultService: projects/***/global/backendServices/***
name: path-matcher-1
routeRules:
- matchRules:
    - prefixMatch: /mobile/
      headerMatches:
        - headerName: User-Agent
          regexMatch: .*Android.*  
  priority: 2
  routeAction:
    weightedBackendServices:
      - backendService: projects/***/global/backendServices/***
        weight: 100
    urlRewrite:
      pathPrefixRewrite: android

- matchRules:
  - prefixMatch: /
  priority: 1
  routeAction:
    weightedBackendServices:
    - backendService: projects/***/global/backendServices/***
      weight: 100

But I can do what I want, I always get following error:

enter image description here

Is there anyone who can tell me what I'm doing wrong?

thx


Solution

  • I was able to find the answer in the documentation: https://cloud.google.com/compute/docs/reference/rest/v1/urlMaps

    pathMatchers[].routeRules[].matchRules[].headerMatches[].regexMatch

    ➡ regexMatch only applies to load balancers that have loadBalancingScheme set to INTERNAL_SELF_MANAGED

    and that is not my case