GCP : LB URL Map based on Request Header values

883 Views Asked by At

https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_url_map#example-usage---url-map-header-based-routing

route_rules {
  priority = 1
  service = google_compute_backend_service.service-a.id
  match_rules {
    prefix_match = "/"
    ignore_case = true
    header_matches {
      header_name = "abtest"
      exact_match = "a"
    }
  }

Probably this is closest to what i need. But as part of priority 1 rule, i need to check that header contains minimum 2 headers, request.scheme is https and request is from a predefined IP.

How to implement such rule?

Can Common Expression Language (CEL) be used here? something like:

has(request.headers['referer']) && request.headers['referer'] != ""
1

There are 1 best solutions below

1
blueboy1115 On

For sure, Custom headers could be created on GCP HTTPS Load Balancer, and you are able to use Common Expression Language (CEL).

Just take a look about the Limitations.