Custom Domains for GitHub Pages

Jekyll / July 05, 2018

GitHub Documentation on Setting up Custom Domains will not that great if you do not know what you are supposed to do.

Here’s what you need to do to setup your own Subdomain.

Create a CNAME file on your repo root. Then push your code to GitHub.

echo pubudu.kubefire.com > CNAME

Add a CNAME record in your DNS Provider pointing to your GitHub domain. I am using GoDaddy for DNS.

CNAME

I did not find a way to enable HTTPS from withing GitHub. There was an article on using a CDN to enforce HTTPS to your site.

If you have an NGINX in the Public Domain adding configuration like below to the conf files will route traffic from https://pubudu.kubefire.com to https://welagedara.github.io where your GitHub Pages are.

server {
    listen 443 ssl;
    server_name pubudu.kubefire.com;

    ssl_certificate /etc/nginx/ssl/kubefire.crt;
    ssl_certificate_key /etc/nginx/ssl/kubefire.key;

    location / {
        proxy_pass https://welagedara.github.io;       
    }
}

Photo Credits

unsplash-logoAgnieszka Boeske