0

For example, there are the following applications deployed as App Engine and Cloud Run services.

A) app-1-api as Cloud Run service

B) app-2-api as App Engine service

C) app-1-frontend a NextJS app as Cloud Run service

D) app-2-frontend a static website hosted as Cloud Run service

I found an article that describes how serverless NEGs with Google Cloud Balancer can glue all these services together behind a single domain. I would like to achieve the following routing:

  1. A request to api.example.com should hit service A

  2. A request to reporting-api.example.com should hit service B

  3. A request to reporting.example.com should hit service D

  4. If a request matches the path *.example.com and none of the paths 1 - 3, then the request should hit service C.

I haven't found anything in regards to the wildcard subdomain in 4. Is all this possible? If not, what GCP alternatives are there?

Thank you.

jz22
  • 111
  • 3

1 Answers1

0

The name of that you are looking for is URL Map.

URL maps are used with the following Google Cloud products:

  • External HTTP(S) Load Balancing (global, regional, and classic modes)

  • Internal HTTP(S) Load Balancing

  • Traffic Director

The hostname must be a fully qualified domain name (FQDN). The hostname can't be an IPv4 or IPv6 address. For example:

Works: example.com

Works: web.example.com

Works: *.example.com

Doesn't work: 35.244.221.250

Check the reference about how to Add a host rule

Before to start with the URL map, please familiarize yourself with URL map concepts., such as:

  1. How URL maps work
  2. Naming
  3. URL map components
  4. URL redirects

For example, with an external HTTP(S) load balancer, you can use a single URL map to route requests to different destinations based on the rules configured in the URL map:

Requests for https://example.com/video go to one backend service.

Requests for https://example.com/audio go to a different backend service.

Requests for https://example.com/images go to a Cloud Storage backend bucket.

Requests for any other host and path combination go to a default backend service.

Arden Smith
  • 432
  • 2
  • 8