π Host Static Websites with GCS
Google Cloud Storage (GCS) makes it easy to host static websites without managing web servers. You can start with a simple public bucket to serve files directly, or enhance it with a global load balancer to unlock features like CDN, clean URLs, and custom error pages.
πΊ Architecture Overview
This diagram shows two ways to serve static files from a public GCS bucket:
β Direct GCS Hosting
- Serves files via
https://storage.googleapis.com/your-bucket/...
- Quick and simple
- Ideal for testing or budget-conscious deployments
β Load Balancer Extension
- Adds Cloud CDN, Load Balancer, and Static IP
- Enables clean root domain, custom error pages, and faster global delivery
- Best for production setups
You can start with Direct GCS, and later extend via Load Balancer without changing your storage setup.
π§± Hosting Comparison
Feature | Direct GCS | Load Balancer Extension |
---|---|---|
Root Access | Returns XML listing | β Serves index.html cleanly |
Error Pages | Default GCS XML error | β Custom 404.html supported |
CDN Support | β Not available | β Cloud CDN enabled |
Static IP | β Not available | β Global IP address |
Setup Effort | β Very easy | β οΈ Requires network setup |
Monthly Cost | π ~\$0.03 (free tier) | π° ~\$20+ |
[ index.html ] β accessible directly
[ 404.html ] β not automatically served on error
π Why Extend with Load Balancer?
- Clean root domain (
https://yourdomain.com/
) - SEO-friendly behavior
- Faster global delivery via CDN
π‘ Recommendation Guide
Scenario | Suggested Setup |
---|---|
Learning / Testing | Direct GCS |
Production Website | Load Balancer |
Budget-Conscious | Direct GCS |
SEO / CDN Requirements | Load Balancer |
π Further Reading
To deploy this setup with minimal effort, use the fully documented and ready-to-deploy Terraform project: tf-gcp-gcs-static-site-demo
Top comments (0)