Using Cloudflare for (free) HTTPs

If you’ve completed the making a Hugo Site the hard way blog series, you may encounter an annoying issue. Your blog will probably be unsecured on HTTP rather than the encrypted HTTPS. Getting an SSL certificate with cloud providers like Google Cloud requires renting out a load balancer which can cost upwards of $20/month!

There is a free alternative in the form of Cloudflare which provides SSL certification for free via proxy.

Change name servers to Cloudflare’s

First you will need to setup an account with Cloudflare. Add your site to CloudFlare and go under DNS. You should see CloudFlare’s name servers.

You can replace the name servers for your domain in your cloud provider’s interface. Here is how it looks like in Google Cloud Domains: Change your name servers to use cloudserver

You will also need to add CNAME records to Cloudflare’s DNS settings for your domain. CNAME record and TXT verification

Activate SSL/TLS settings in Cloudflare

You can setup encryption in Cloudflare’s SSL settings menu like so: Cloudflare SSL/TLS settings

Either Flexible or Full should work.

Add a Page Rule

Finally you want to redirect your “www” subdomain traffic (ie: http://www.mysite.net) to the root domain (ie: https://mysite.net) using a Page Rule.

Go to Rules » Page Rules and

Page Rules

Updating the site

If you are using a tool like HUGO you may want to update the baseURL in the config.toml to be https:

baseURL = "https://mysite.com"

Note: At this point you may also encounter issues with certificates, especially if you did not set up your DNS with Cloudflare to begin with. If you encounter prolonged trouble with this, I recommend trying out a new domain registered with Cloudflare to begin with.

References:

  1. CloudFlare and Google Cloud for Hosting a Static Site

  2. Static site hosting for (nearly) free with Cloudflare

  3. Hosting a static website with a custom domain over HTTPS

Related Posts

Why Big Tech Wants to Make AI Cost Nothing

Earlier this week, Meta both open sourced and released the model weights for Llama 3.1, an extraordinarily powerful large language model (LLM) which is competitive with the best of what Open AI’s ChatGPT and Anthropic’s Claude can offer.

Read more

Host Your Own CoPilot

GitHub Co-pilot is a fantastic tool. However, it along with some of its other enterprise-grade alternatives such as SourceGraph Cody and Amazon Code Whisperer has a number of rather annoying downsides.

Read more

All the Activation Functions

Recently, I embarked on an informal literature review of the advances in Deep Learning over the past 5 years, and one thing that struck me was the proliferation of activation functions over the past decade.

Read more