0

I am trying to achieve something simple yet I can't figure out why it isn't working. I have two Cloud Run function that are deployed independent from each other as two cloud run services. I want to access them from an external Load Balancer so that:

-example.com takes me to the 1st function,

-example.com/api takes me to the 2nd function

For above to happen I have written the following path rule in the Advanced host and path rule part of Load Balancer

defaultService: projects/example-proj/global/backendServices/fun1
name: matcher1
routeRules:
- matchRules:
  - prefixMatch: /api/*
  priority: 1
  routeAction:
    weightedBackendServices:
    - backendService: projects/example-proj/global/backendServices/fun2
      weight: 100

With this setup I am able to access 1st function by going to example.com, but going to example.com/api gives me 404 error.

1 Answer 1

1

To solve this, you need to remove the wildcard mask “/*” from your prefixMatch. Your code should look like this:

defaultService: projects/example-proj/global/backendServices/fun1
name: matcher1
routeRules:
- matchRules:
  - prefixMatch: /api   #Just remove “/*” on this line.
  priority: 1
  routeAction:
    weightedBackendServices:
    - backendService: projects/example-proj/global/backendServices/fun2
      weight: 100

Your provided prefixMatch /api/* attempts to match any directory or file within the /api path. If the path or file does not exist, you will likely receive an error message.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.