Free Website Hosting with GitHub Pages with a Free SSL certificate
I have an app, Bongstick and recently I planned to make a website for it. As planned, I purchased the domain name bongstick.com. Now I need to build a website and host it somewhere. My blog shuvankar.com is hosted in GoDaddy shared hosting service. I was looking for a free and reliable hosting service. After some search, I came to know about GitHub Pages. Here I can host a static webpage and load it from a custom domain. Let me share how can I host a free website using Github pages and apply for a free SSL certificate using Cloudflare.
First It needs to create a repository on Github. Make sure the repo is public, otherwise you cannot use it as Github Page as a free service. Add some website source code to that. I am not going into detail about how to push code on Github. It’s very easy and there are a lot of tutorials available for that. Goto Settings -> Pages -> Select Branch as master -> Save. The page will be published in a URL (e.g. https://sonu041.github.io/bongstick.com/)
In the custom domain enter the domain name you have. For me, I entered bongstick.com
Now your DNS needs to know, that the hostname should resolve the Github page. There is a dedicated GitHub help page for configuring the apex domain but still let me tell in short what I have done in GoDaddy. Log in to the GoDaddy console. Click on triple-dot of domain name -> DNS Management. Add below A DNS Records.
188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168
After some time you can see your custom domain is resolving the Github Pages content. This will work only for a static page. GitHub Page is not supporting any server-side code. So consider the use case before trying this.
Now our free website is ready and we need an SSL certificate. There are multiple free SSL certificate providers like letsencrypt, sslforfree, zerossl, etc but everyone has some disadvantages like it’s free for a very limited period and you need to renew frequently. Some have a limited number of certificates per account. My favorite is Cloudflare. Apart from Free SSL, it has some other good features as well. Let’s see how to configure it.
First, log in to Cloudflare. Add a site. First, you need to change the nameserver of your domain so that every request goes via Cloudflare. Go to the GoDaddy DNS Management console (same screen as above)
Change the name server to that is provided by Cloudflare.
As the nameserver changed, the GoDaddy A DNS records have no value. We need to add A DNS records in Cloudflare. You may think when it is not in use why I mentioned GoDaddy configuration. It’s just for knowledge purposes only. If you don’t need an SSL certificate then configuration in GoDaddy is enough.
Go to the Cloudflare DNS tab and make sure the below A-type entries are made. In A DNS record name, enter @ for root (bongstick.com).
Go to the Github page and check Enforces HTTPS. It will take some time to reflect on the changes. Be patient and try after some time if the intended result doesn’t come immediately.
In Cloudflare, you can see that a managed edge certificate is created.
If you have a server and want to install Origin Certificates on the origin server that can be done as well.
A lot of features are available in Cloudflare. Explore the Cloudflare console and experiment with it. Enjoy the free website with a free SSL certificate :).