The One and the Many

Hosting websites in Google Cloud Storage

I recently switched all my websites off a little VPS. They're now all hosted in Google Cloud Storage (with one in GitHub Pages).

This isn't the most groundbreaking achievement but I found it so smooth and I'm really happy with it. It is much less work for me and simplified my setups.

Hosting on a VPS has benefits of course. You get full control. For a couple of my sites I had written complicated rewrite rules to make the URLs a little nicer. As well, I could see all the logs. Basically I could customise things exactly how I wanted them.

However it was also work. I logged in each week to update packages. I had previously automated retrieving Let's Encrypt certificates for the sites. I had a setup to pull logs that I'd glance at.

All in all it was overkill for very simple sites.

I recently handed over control over one of the sites. It was the most complex one and required PHP (because of how I built it, which today I would not have done). I realised I didn't need a VPS any more. So I set out to move the rest out of it.

Initially I thought I could stick all the sites in GitHub pages. Unfortunately GitHub Pages only works for public repositories (unless you pay, which again seemed overkill for these sites). So I was only able to move one site there (a few sites I am not so comfortable making public like that, despite being militant about free software).

I knew it was possible to host sites in Google Cloud Storage so I went and looked for how to do that. I expected it to be painful. I had vague ideas about fighting with hostnames. But it was absurdly simple. Google has a guide for it.

It's really just (I already had a GCP project):

  1. Create a bucket (gsutil mb gs://www.example.com)
  2. Upload files (gsutil -m rsync -d -r site_dir gs://www.example.com)
  3. Make it public (gsutil iam ch allUsers:objectViewer gs://www.example.com)
  4. Make index.html the default page (gsutil web set -m index.html gs://www.example.com)
  5. Create a CNAME record pointing at c.storage.googleapis.com

I also stuck Cloudflare in front. Because I love Cloudflare and they take away thinking about certificates too!

Now I don't have to deal with monitoring or updating anything. It is very freeing and simple. I even converted this blog to it and it took all of 5 minutes.

You might argue that I'm handing over control and locking myself in to proprietary systems. Not to mention helping to make the web more centralised. Certainly that's true and a few years ago I would have never considered some of this. But these days I feel more and more that it is better to reduce my responsibility. It is less work for me and these services are going to run things better and more securely than I would. I don't need to turn hosting a few HTML files into rocket surgery.

Back

Comment