A production-ready guide for hosting a static website on Google Cloud Storage using Cloudflare as the CDN, SSL provider, and reverse proxy.
User (HTTPS)
│
▼
Cloudflare Edge
(SSL, CDN, Cache, WAF)
│
│ HTTP/HTTPS
▼
Google Cloud Storage Bucket
(Static Website)
- Google Cloud Project
- Billing enabled
- Cloud Storage API enabled
- Cloudflare-managed domain
- gcloud CLI installed and authenticated
Important: The bucket name must exactly match your hostname.
Example:
www.example.com
export DOMAIN="www.example.com"
gcloud storage buckets create gs://$DOMAIN --location=asia-south1gcloud storage cp index.html gs://$DOMAIN/index.htmlUpload CSS, JS and images similarly.
gcloud storage buckets update gs://$DOMAIN --web-main-page-suffix=index.html(Optional)
gcloud storage buckets update gs://$DOMAIN --web-error-page=404.htmlgcloud storage buckets add-iam-policy-binding gs://$DOMAIN --member=allUsers --role=roles/storage.objectViewer| Setting | Value |
|---|---|
| Type | CNAME |
| Name | www |
| Target | c.storage.googleapis.com |
| Proxy | Proxied (Orange Cloud) |
| TTL | Auto |
Cloudflare → SSL/TLS
- SSL Mode: Full
- Always Use HTTPS: Enabled
- Automatic HTTPS Rewrites: Enabled
curl -I https://www.example.comExpected:
- HTTP/2 200 OK
- server: cloudflare
gcloud storage cp index.html gs://$DOMAIN/index.htmlThen purge the Cloudflare cache if required.
Bucket name doesn't match hostname.
Objects aren't publicly readable.
Purge Cloudflare cache.
| Solution | Best For | Cost |
|---|---|---|
| GCS + Cloudflare | Static websites | ⭐ Very Low |
| Firebase Hosting | Static websites | Low / Free Tier |
| GitHub Pages + Cloudflare | Personal sites | Free |
| Cloud Run + Cloudflare | Dynamic apps | Pay per use |
| Compute Engine (Nginx) | Full web server | VM charges |
| HTTPS Load Balancer + GCS | Enterprise | Higher |
| Service | Typical Cost |
|---|---|
| Cloudflare Free Plan | $0/month |
| SSL Certificate | Included |
| Google Cloud Storage | Pay for storage + egress |
| Domain | Depends on registrar |
For most personal portfolios or documentation websites, the total monthly cost is typically only a few dollars unless bandwidth is very high.
