ahmetb / cloud-run-faq

Unofficial FAQ and everything you've been wondering about Google Cloud Run.
https://cloud.run
Creative Commons Attribution 4.0 International
2.32k stars 124 forks source link

Can I add a wildcard domain to Cloud Run? #150

Closed tmaier closed 3 years ago

tmaier commented 3 years ago

Hi,

is it possible to connect *.example.com to a Cloud Run instance?

Am I getting a valid wildcard certificate for it? Note that Let’s Encrypt would support wildcard certificates and when I understand correctly, this is what GCP uses under the hood.

ahmetb commented 3 years ago

Have you read https://dev.to/googlecloud/a-wildcard-for-your-cloud-run-services-4haa ?

tmaier commented 3 years ago

Yes, I read it.

I want to deploy an application to Cloud Run, which handles requests to subdomains by itself. (Every customer gets an own subdomain)

When I understand the article correctly, then it maps a wildcard domain to the CNAME entry of google, but then it maps an individual domain to one "Cloud Run instance"/service.

See $ gcloud beta run domain-mappings create --service $SERVICE --domain $SERVICE.gl.asnt.app

ahmetb commented 3 years ago

Yeah, you need to create the mapping ahead of time. You probably need to use GCLB in front of Cloud Run to do what you want, and you might need to write a proxy to route these requests to the correct Cloud Run service (assuming you have multiple, if you just have a multitenant service, then it's easier). In this setup, you wouldn’t be using domain mappings.