How to Host Static Websites on Google Cloud Storage
John  Ajera

John Ajera @jajera

About: Platform Engineer

Location:
Wellington, New Zealand
Joined:
Nov 20, 2024

How to Host Static Websites on Google Cloud Storage

Publish Date: Jul 6
2 0

🌐 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
Enter fullscreen mode Exit fullscreen mode

🚀 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

Comments 0 total

    Add comment