Skip to content
DuBlog

Using Cloudflare for (free) HTTPs

Using Cloudflare for free static sight hosting over 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

All posts