Google Cloud Run Website behind Cloudflare
Hosting static website on Google cloud run has becoming popular recently (well, aside from CDN hosting) But there are some extra steps needed in order to put Cloud Run hosted website behind Cloudflare’s reverse proxy.
Mapping Custom Domain
If you haven’t done it already, first, you’ll need to map custom domain to your Google Run service by click “Manage Custom Domain”
Next add domain mapping. If you’re not using Google Domain as registrar, you’ll need to verfiy the domain ownership.
Once the verification is complete, you’ll get the DNS information (to be added to Cloudflare)
Note: For “www” subdomain, you will need to add domain mapping separately from root domain.
Cloudflare Setting
You will get DNS information from Google Cloud Console when mapped domain. (They should be ghs.googlehosted.com or something similar) Add those DNS records to Cloudflare and enable the reverse proxy.
Next is SSL/TLS. Google Cloud Run will automatically manage SSL certificate for you so choose “Full” in SSL/TLS setting in Cloudflare.
However, this will take some time before SSL certificate setup is complete. During this time you won’t able to access website (couple hours from my experience, but could be up to 24 hours)
That’s all for this tutorial. If you like it, check out our YouTube channel our Facebook page to stay tune for more dev tips and tutorials