Host Your Static Website on GCP

A step-by-step guide to hosting a static website on Google Cloud Platform — works with any domain registrar.

G

Hey there! I recently went through the process of moving my website hosting from traditional providers like GoDaddy and Squarespace over to Google Cloud Platform. I wanted to take advantage of GCP's more advanced features — things like custom load balancing, better performance controls, and more flexibility with how my sites are served.

The process wasn't always straightforward, and I found myself piecing together information from different sources. So I put together this guide with the exact steps I took, hoping it makes things easier for you if you're looking to do the same.

These steps should work regardless of where your domain is currently registered — whether that's GoDaddy, Squarespace, Namecheap, Google Domains, or anywhere else. The DNS concepts are universal; you're just updating nameservers and records.

1

Pointing Nameservers to GCP

To manage your site in Google Cloud, you need to tell your domain registrar to hand over DNS control to GCP.

  1. In GCP: Go to Network Services Cloud DNS. Create a Public Zone for your domain (e.g., example.com).
  2. Copy Nameservers: Note the four nameservers Google provides (e.g., ns-cloud-e1.googledomains.com).
  3. At Your Registrar: Log into your domain registrar (GoDaddy, Squarespace, Namecheap, etc.) and find the DNS or Nameservers settings for your domain.
  4. Action: Select Use Custom Nameservers (or similar) and enter the four GCP nameservers.

Once saved, all DNS records at your registrar are ignored. You must manage all future records (email, verification, subdomains, etc.) in GCP Cloud DNS.

2

Domain Verification

Google needs to prove you own the domain before it serves traffic via GCP.

  1. Get the Code: During setup (or in Google Search Console), copy the CNAME or TXT record provided.
  2. Add to Cloud DNS:
    • Go to your DNS Zone in GCP. Click Add Record Set.
    • Type: Select CNAME (or TXT).
    • DNS Name: Paste the "Label/Host."
    • Canonical Name: Paste the "Destination/Target."
  3. Verify: Return to the verification tool and click Verify. Propagation usually takes 5–15 minutes.
💡

Crucial: Always add a trailing dot . at the end of the destination (e.g., googlehosted.com.).

3

Cloud Storage Setup

  1. Create Bucket: Go to Cloud Storage Buckets. The bucket name must be exactly your domain (e.g., www.example.com).
  2. Upload Content: Upload your index.html and assets.
  3. Enable Public Access:
    • Go to the Permissions tab. Click Grant Access.
    • Principal: allUsers
    • Role: Storage Object Viewer
  4. Set Main Page: Click the three dots on the bucket row › Edit website configuration. Set Index page to index.html.
4

Enabling HTTPS (Load Balancer)

Google Cloud Storage does not support HTTPS for custom domains directly. You must use a Load Balancer.

Choice A: Add to an EXISTING Load Balancer

$0 extra

If you already pay ~$18/month for a load balancer, use this to avoid a second charge.

  1. Edit LB: Go to Network Services Load Balancing. Click your LB and select Edit.
  2. Frontend: Find the HTTPS (Port 443) entry. Click Create a new certificate.
    • Mode: Google-managed. Enter example.com and www.example.com.
    • Add this as an Additional Certificate.
  3. Backend: Go to Backend Configuration. Create a New Backend Bucket pointing to your new storage bucket.
  4. Routing: In Routing Rules, add a new rule:
    • Host: example.com and www.example.com
    • Path: /*
    • Backend: Select the backend bucket you just created.
  5. Update: Click Update at the bottom.

Choice B: Create a NEW Load Balancer

~$18/month
  1. Start: Go to Load Balancing Create Load Balancer. Choose Application Load Balancer (HTTP/HTTPS) and Global/External.
  2. Frontend: Create two rules:
    • Rule 1: Protocol: HTTPS, Port: 443. Create a Google-managed certificate for your domain.
    • Rule 2: Protocol: HTTP, Port: 80. (Enable HTTP to HTTPS Redirect if available).
  3. Backend: Create a Backend Bucket pointing to your storage bucket.
  4. Routing: Set the "Default" rule to point to your backend bucket.
5

Final DNS Pointing

Once the Load Balancer is set up, you must point your domain to its Static IP Address.

  1. Find IP: On the Load Balancer details page, copy the Frontend IP Address.
  2. In Cloud DNS:
    • Delete any old CNAME records for your domain.
    • Add an A Record for @ (root). Value: [Your LB IP].
    • Add an A Record for www. Value: [Your LB IP].
  3. Wait for SSL: The certificate status will show PROVISIONING until Google detects that the domain points to the LB IP. This usually takes 30–60 minutes.

Once the SSL certificate shows ACTIVE, your site is live with HTTPS!