How to build a static site with Google Cloud Storage (Load Balancer, CDN, SSL)


This article describes how to build a static site with Google Cloud Storage with Load Balancer and CDN, SSL, DNS etc.

🎉 Prerequisite requirements

It is assumed that the following requirements will be met:

  • Host your images and HTML, etc in Google Cloud Storage
  • Deliver images, etc. using HTTPS URL
  • Subscribe to your specific domain

🎂 What to do

  • A. Setting up Google Cloud Storage
  • B. Configuring Google Cloud Load Balancer

🚜 A. Configuring Google Cloud Storage

(1) Make your domain proprietary on Google Search Console

Please refer to the following page to check the ownership of the domain “www.example.com" on Google Search Console.

https://cloud.google.com/storage/docs/hosting-static-website?hl=ja.

This can be confirmed by setting the TXT specified in the DNS.

(2) Creating a bucket on the Google Cloud Storage screen

Create a bucket named “www.example.com".

Do not put _ in the domain name because it will cause an error later.

(3) Set permission to view Storage Objects for allUsers.

Add a public status to the bucket “www.example.com" that I made earlier by referring to the following page.

https://cloud.google.com/storage/docs/access-control/making-data-public?hl=ja

(4) Set c.storage.googleapis.com to CNAME in DNS

Set c.storage.googleapis.com in the CNAME of “www.example.com" on DNS.

🚕 B. Configuring the Google Cloud Load Balancer

(1) Create a Load Balancer with a bucket as a backend

Create Load Balancing with a bucket as the backend.
Points to note are as follows.

  • Do not use ephemerals for IP addresses. Set a fixed IP.
  • Allow CDNs on demand
  • The network will be at a premium.
  • There is an option that Google automatically creates an SSL certificate in the HTTPS setting, so I use it.

(2) Configure Load Balancer’s IP in DNS

Set the IP of the Load Balancer in the A Type of “www.example.com" on the DNS.

(3) Waiting for DNS penetration

After 5-10 minutes of waiting for DNS penetration, you will get a green mark on your SSL.
Then, try to make a communication check.

🐹 References

https://medium.com/veltra-engineering/google-cloud-storage-tease-site-bfe648567433

🖥 Recommended VPS Service

VULTR provides high performance cloud compute environment for you. Vultr has 15 data-centers strategically placed around the globe, you can use a VPS with 512 MB memory for just $ 2.5 / month ($ 0.004 / hour). In addition, Vultr is up to 4 times faster than the competition, so please check it => Check Benchmark Results!!