Enabling SSL on custom domain Github Pages with Cloudflare

Post by dangsonbk on 10-09-2018

I'm currently hosting this blog on Github Pages. By default Github Pages can be served over SSL but not in my case where I am using a custom domain. However, I found an easy way to set this up simple and free with Cloudflare.

Cloudflare offers a free plan for personal webpages like my own with shared SSL certificate and 3 page rules. You just have to create an account, follow the instructions to migrate your DNS settings from your currently working domain, set your domain’s nameservers to the ones provided by Cloudflare. After all, make sure the “Always Use HTTPS” option enabled in the Crypto tab.

When you finish these above steps in Cloudflare, it's time for Github Pages settings. From repository navigation bar, in Setting tab, scroll down to Github Pages area and make sure the Enforce HTTPS setting checked. In case it's not, clear the Custom domain text box, click save and reenter your domain again, this will trigger Github to active Enforce HTTPS setting.

Github Pages setting

It will take a while until all DNS changes take effect, some services may inform you that it's up to 24 hours, so be patient. Please also note that your site will use DNS hosting provided by Cloudflare as well as Cloudflare-provided certificate for SSL, this may or may not be ideal depending on your needs. If you have your own certs, you will not able to use them on this website anymore. Secondly, you may need more than 3 Page Rules, which is limited for free plan. For me, Cloudflare supports everything I need, 3 rules are not much but actually I don't even need to use one.

If your need is just to get SSL working with your Github Pages and the limitations of the free plan are not an issue, I would highly recommend Cloudflare for it.

tags: cloudflare