Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

url map hostname and path rule query

Based off the following url map in this doc:
https://cloud.google.com/load-balancing/docs/url-map-concepts#example-url-map-workflow

 

 

 

 

 

creationTimestamp: '2021-03-05T13:34:15.833-08:00'
defaultService: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/org-site
fingerprint: mfyJIT7Zurs=
hostRules:
- hosts:
- '*'
pathMatcher: video-matcher
- hosts:
- example.net
pathMatcher: video-matcher
id: '8886405179645041976'
kind: compute#urlMap
name: video-org-url-map
pathMatchers:
- defaultService: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/video-site
name: video-matcher
pathRules:
- paths:
- /video/hd
- /video/hd/*
service: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/video-hd
- paths:
- /video/sd
- /video/sd/*
service: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/video-sd
selfLink: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/urlMaps/video-org-url-map

 

 

 

 

Say the domain name is "videos.com",  the following are my host and path rules for "videos.com":

host_path_rules.png

I have a few queries:

1. What is the difference between "All unmatched (default)" and "*".

2. What happens if the hostname is unknown.com/video/hd.

Is the backend service selected as `org-site` or `video-hd`?

3. What happens if the hostname is unknown.com/hello.

Is the backend service selected as `org-site` or `video-site`?

4. In this case, would the default service of the path matcher `video-matcher` always take precedence over the default service of the url map `org-site`.

Solved Solved
0 6 530
1 ACCEPTED SOLUTION

Yeah, sure!

In your example bs-org-site would never be reachable because it has already all other rules that contemplate any other scenario. * is a wildcard, is a decision that you allow any value for that variable. All unmatched (default) is technically a wildcard as well, but it's not (or shouldn't) be a decision, should be a void where things are thrown whenever nothing else can be done.

The logic goes that the lb will check first

  • what is your host?
  • Is your host explicitly in the list?
    • Yes: Cool, let's look at the path
    • No: Ok, is there any * defined?
      • Yes: Ok, let's use that, it means the administrator contemplated this
      • No: Ok, let's use the default, as it seems this is not a contemplated case and I will have to fall back to the "standard"

And the same process goes after for path.

FrancoGP_0-1731573312790.png

Going back to the example, and taking in consideration the "flow chart", there is no path in which bs-org-site could be used, the most near thing would be on line 4. If you limit the scope of the path on bs-video-site (the one in the middle) there is a window in which there won't be a match between host and path (right now basically both are wildcards so it's impossible to not find a match) and drop to bs-org-site
This rule, the 4th rule you have in the example is contemplating all scenarios, so it won't let anything fall under the default, hence never reaching bs-org-site

* Should be used when you want to catch all because you thought it through, All Unmatched (default) has to just be there for whenever something escaped your sight. Technically they are the same, but for style/administration they are different, one is a swiss knife while the other is more like a last resort safety net

View solution in original post