DEV Community

John  Ajera
John Ajera

Posted on

How to Host Static Websites on Google Cloud Storage

🌐 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

Top comments (0)