Search code examples
google-cloud-platformload-balancing

How to configure google load balancer to route to cloud run service using url mask but strip service from url


I would like to route to a serverless neg with a url mask placeholder like: /<service>

However is there a way to format the placeholder /<service> so it will remove the match from the url passed to the service?

ie: remove"/service1" and "/service2" from the examples below

Example:

  1. For URL: https://server.com/service1/ the service service1 will see the url as https://server.com/

  2. For URL: https://server.com/service2/about?en the service service2 will see the url as https://server.com/about?en

GCP Load Balancing docs


Solution

  • Yes, you need to create one backend per Cloud Run service (and therefore one serverless neg by backend). Then use URL map (and not url MASK) to route the paths to the corresponding backend.

    If you have a lot of path, it will be long and boring, and less easy than the URL mask, but, it's possible!

    If your question is "can I rewrite the URL with URL mask", that is not possible.