Using GCS directly via CNAME redirects only allows HTTP traffic.
3 ways to solve this:
- To use HTTPS with your own domain, you’ll need to set up Google Cloud Load Balancer, and optionally you’ll want to set up Google Cloud CDN as well.
- An alternative would be to host your domain DNS server at CloudFlare
- An alternative would be to host your SPA on Firebase. All apps have SSL included by default even those with custom domains.
The easiest way is to us CloudFlare
- Sign up to Cloudflare or you can use an existing account. https://www.cloudflare.com/sign-u
- Add domain name of your Google Cloud Project.
- For Cloudflare and Google Cloud Project to work together, you will need to update the DNS records on Cloudflare to point to your Google Cloud Instances.
- First, find the external IP address for your instance:
- Then enter that IP address for the A record of the subdomain that you want this instance to power:
- Make sure that the subdomain is “orange clouded” and that you have updated the nameservers at your registrar to use Cloudflare’s nameservers, and traffic will flow through Cloudflare to your Google Cloud instance!
Resources
Alternative ways: