Jekyll on Amazon S3 part 3

Earlier i wrote posts about deploying a Jekyll site on Amazon S3. post 1 and post 2. I covered:

SSL

This time i am going to walk through some steps for getting your AWS powered Jekyll site use SSL. In this example i’m using CloudFlare free SSL together with a S3 bucket.

CLoudflare logo

Cloudflare now supports SSL in the free plans. This makes it very easy to activate https. You don’t need to buy a certificate the regular way.

Why SSL?

There are many reasons. Here are some good reasons you should switch to HTTPS for your static site today:

  • Security: the traffic is encrypted between your users and your website
  • Protect your users
  • Protect your content
  • Trust. You show the users that your website is secure using https.
  • Better Analytics. Read this
  • Better SEO. https-as-ranking-signal.

More reading

  1. Why your site should be using HTTPS
  2. Now is probably the time to make HTTPS the default on all your sites and apps
  3. Five Reasons you want HTTPS for your Static site
  4. Kom igång med SSL (Swedish)

Create a Amazon S3 bucket

Read my guide if you like. Your bucket must have the same name as your domain (mywebsite.com in this example). Copy your S3 endpoint, ex. mywebsite.com.s3-website-us-west-2.amazonaws.com.

Deploy

Deploy your site to S3:

s3_website push

Setup Cloudflare

Get an account on Cloudflare. Add your website by clicking “Add site”.

Change nameservers

Change the name servers on your domain, if you have your domain on another registrar. Wait for the changes to propagate. You’ll find Cloudflares nameservers in your dashboard. They look like this:

dan.ns.cloudflare.com

and

kara.ns.cloudflare.com

Add CNAME

Add a CNAME record that points to your S3 Bucket. Add your domain mywebsite.com as Name and S3-endpoint as Value. Turn on Cloudflare by making sure the status icon is orange.

Redirect http to https

Under Page Rules, add the following URL pattern: http://*mywebsite.com/*. Then turn on “Always use https”.

If the DNS has refreshed its cache and you’ve succeded in deploying your Jekyll-sajt to Amazon S3, using Cloudflare SSL.

How do i invalidate the cache?

Head over to the Cloudflare dashboard and the tab Caching -> Purge. Or use a cli tool like cloudflare-cli

Cache Expiration?

Look under Cache -> Browser Cache Expiration. Your can Determine the length of time CloudFlare instructs a visitor’s browser to cache files. During this period, the browser loads the files from its local cache, speeding up page loads.