Hosting on GCP

I recently decided to revive my personal website after a long time and decided to go with GoDaddy for domain & Google Cloud Platform (GCP) for hosting - mostly for learning purposes.

Below are the steps I followed to host my static personal website on GCP

Create a Google Cloud Account

Install gcloud and gsutil cli

Copy
curl https://sdk.cloud.google.com | bash
exec -l $SHELL
gcloud init
  • It will ask to log into your Google account. You can also authorize explicitly by gcloud auth login.
  • This should install both gcloud and gsutil

Create and set your project

Copy
gcloud projects create YOUR_NEW_PROJECT_ID
gcloud config set project YOUR_NEW_PROJECT_ID

Make sure billing is enabled too (free tier is typically enough)

Enable required services

Copy
gcloud services enable storage.googleapis.com

One time setup required per project

Create a Storage Bucket

Copy
gcloud storage buckets create YOUR_BUCKET_NAME --location=YOUR_REGION --uniform-bucket-level-access

# Using gsutil mb (make bucket)
gsutil mb -l YOUR_REGION gs://YOUR_BUCKET_NAME/

--uniform-bucket-level-access ensures simplified permission management.

Upload Your Website Files

Suppose your files are in a folder ./website (must contain at least index.html).

Copy
gcloud storage cp ./website/* gs://YOUR_BUCKET_NAME/ --recursive

# Using gsutil cp
gsutil cp -r ./website/* gs://YOUR_BUCKET_NAME/

# Using gsutil sync
# Only syncs the file additions/deletes/updates
# Preferable if large number of files 
gsutil -m rsync -r -c -d website gs://YOUR_BUCKET_NAME

Make your files public

Copy
gcloud storage buckets add-iam-policy-binding YOUR_BUCKET_NAME \
  --member=allUsers \
  --role=roles/storage.objectViewer

# Using gsutil ch 
gsutil iam ch allUsers:objectViewer gs://YOUR_BUCKET_NAME

This allows the public to access your files.

Configure the Bucket for Website Hosting

Set your index.html and (optional) 404.html

Copy
gcloud storage buckets update YOUR_BUCKET_NAME --website-main-page-suffix=index.html --website-not-found-page=404.html

# Using gsutil web set 
gsutil web set -m index.html -e 404.html gs://YOUR_BUCKET_NAME

Access your website

Your website should now be visible at https://YOUR_BUCKET_NAME.storage.googleapis.com

Linking godaddy domain to GCP

Name Your Bucket Correctly (Important!)

For domain mapping to work - your bucket name MUST match your domain exactly. (www.yourdomain.com)

  • If you didn’t create the bucket with this exact name, you’ll need to create a new bucket.
  • When you create a bucket with the domain name, google will try to authorize if you are the rightful owner of the website

Add a CNAME Record in GoDaddy

Go to your GoDaddy dashboard > Select your domain (e.g., yourdomain.com) > Go to DNS Management > Add Record. Add this CNAME record:

  • Type: CNAME
  • Name: www
  • Value: c.storage.googleapis.com
  • TTL: 1 hour (default is fine)

Forward root domain (naked domain) (Optional)

GoDaddy can't CNAME a root domain (yourdomain.com) directly — that’s a DNS limitation. But you can set up a Domain Forwarding rule in GoDaddy:

  • Forward yourdomain.comhttps://www.yourdomain.com
  • Enable Permanent 301 Redirect and Forward with masking (optional).

Now both yourdomain.com and www.yourdomain.com will work.

Google Cloud Load Balancer + HTTPS (Optional)

Create a backend bucket

Copy
gcloud compute backend-buckets create STATIC_BACKEND_NAME \
  --gcs-bucket-name=YOUR_BUCKET_NAME \
  --enable-cdn

This tells GCP "this backend is tied to my GCS bucket."

Reserve a global static IP

Copy
gcloud compute addresses create LB_STATIC_IP \
  --global

Name it LB_STATIC_IP appropriately.

  • Get the reserved IP and save it as you'll use it soon in GoDaddy
Copy
gcloud compute addresses describe LB_STATIC_IP --global --format="get(address)"

Create SSL Certificate (Managed)

Copy
gcloud compute ssl-certificates create SSL_CERT_NAME \
  --domains=www.yourdomain.com

GCP will auto-provision a Let’s Encrypt-like cert for you.

Create URL Map and Target Proxy

Copy
gcloud compute url-maps create URL_MAP_NAME \
  --default-backend-bucket=STATIC_BACKEND_NAME


gcloud compute target-https-proxies create HTTPS_PROXY_NAME \
  --ssl-certificates=SSL_CERT_NAME \
  --url-map=URL_MAP_NAME

Create Forwarding Rule

Now, tie the static IP to HTTPS frontend

Copy
gcloud compute forwarding-rules create HTTPS_FORWARDING_RULE \
  --address=LB_STATIC_IP \
  --global \
  --target-https-proxy=HTTPS_PROXY_NAME \
  --ports=443

Load Balancer is READY now!

  • It will automatically serve your static website via HTTPS.
  • URL: https://www.yourdomain.com. Once the SSL cert is active — takes a little time.

Update DNS at GoDaddy

Go back to GoDaddy DNS settings:

  • Add A record:
    • Type: A
    • Host: @
    • Points to: STATIC IP ADDRESS
  • (Optional) Add another A record:
    • Host: www
    • Points to: STATIC IP ADDRESS
  • TTL: 1 hour (default is fine)

Final Flow diagram

Copy
User Browser (HTTPS) 
     ↓
Google Load Balancer (Static IP, HTTPS cert)
     ↓
Backend Bucket → GCS Static Website

PS

  • SSL Certificate may take 10–30 minutes to provision.
  • The domain MUST point to the Load Balancer IP for certs to validate.
  • You pay a small fee for the static IP and Load Balancer (~$5/month depending on use).