Following on from my last post about deploying your side-projects for ‘free’, I’ve found a nice way to keep costs down for static site-hosting using Google Cloud Storage (GCS) with HTTPS.

Static Hosting

GCS supports static-site hosting just like S3. It is pretty simple and you can find Google’s guide for this here. In short the steps are:

Create a bucket with the domain name you own (it will guide you through the verification process if needed Upload your assets Set the bucket to ‘website’ mode and set public read permissions. Create a CNAME on your domain pointing to the GCS location:

NAME TYPE DATA www.example.com CNAME c.storage.googleapis.com.

With the above setup you now will be able to hit your own domain with the assets being served by GCS - but the problem here this is only over HTTP - if you are trying to reference these assets in an HTTPS page, browsers will block the request so we need SSL.

SSL for free

In order to get HTTPS serving from your GCS bucket Google requires you to setup a Google Cloud Load Balancer which fronts your GCS bucket. This LB will provision a cert for the domain you set but all of this costs ~$18/mn. For a side project this isn’t overly fun - so here is a free alternative - enter Cloudflare.

Clouldflare CDN’s free plan allows you to have them front your site and it will issue and enforce SSL from your users to their edge nodes, and then it will talk back to GCS over HTTP.

Cloudflare does this by fronting your domain and issuing an SSL certificate. The request between users and Cloudflare will be encrypted by this certificate. The page you need to check in Cloudflare is under ‘SSL/TLS’ and ensure your encryption mode is set to ‘Flexible’.

Now, this isn’t best-practice if what you are sending over that last hop needs to be secure, but for me this is an acceptable risk for static - public - assets you are serving from GCS.

Hopefully this will help you save that ~$18/m that you maybe spending on Google Cloud Load Balancing for your static asset serving.

Hit me up on Twitter @alexolivier if you have any questions or want to talk more.