Post

Deploy Secure Github pages with Custom Domain on Cloudflare

We can enable HTTPS on Github pages with custom domain name on Cloudflare.

Deploy Secure Github pages with Custom Domain on Cloudflare

According to the previous blog about moving to Github pages below.

I got some stuffs to share about how to enable HTTPS on Github pages with our own domain name on Cloudflare.


Prerequisites

  1. Github pages that is already online in the url https://<USERNAME>.github.io.
  2. Domain name
  3. Cloudflare account
  4. IP addresses of Github pages according to Managing a custom domain for your GitHub Pages site

Action steps

Cloudflare configurations

  1. Go to Cloudflare > Select a domain name > Menu DNS > Records
  2. Add A records with “Content” as Github pages IP addresses and “Proxy status” as “DNS only”.
    Set “Name” as “@” if it’s root which means it’s top level domain and Cloudflare will show the domain name instead of “@” after adding the record.
  3. Add CNAME record with “Content” as our domain name, “Name” as “www”, and “Proxy status” as “DNS only”.

By default, new record will have “Proxy status” as “Proxied” which means it will go through Cloudflare’s network.

proxied

But we don’t need it because we are going to enable HTTPS by Github pages.

Make sure that we turn it off and the records have “Proxy status” as “DNS only”.

These are my configurations.

dns only

Github pages configurations

  1. Go to the repo of our Github pages.
  2. Select tab “Settings” > “Code and automation” > “Pages”
  3. Add our domain name under “Custom domain” section and click Save
  4. The checkbox “Enforce HTTPS” should be clickable and we click it.
  5. Github will issue the certificate and it takes some time to complete.

github-https

If the Cloudflare configurations have “Proxied” status, Github will not be able to issue the certificate.

And we would see the message: “Unavailable for your site because your domain is not properly configured to support HTTPS”.


Test it

  1. Run dig command then we should see the IP addresses from Github pages.

    1
    
     dig <DOMAIN_NAME> +noall +answer -t A
    

    dig

  2. Try to access the domain name. Our webpage should be rendered properly with HTTPS.


References

This post is licensed under CC BY 4.0 by the author.