Github pages is a very convenient way to host both personal websites, and project websites. Websites are linked to a git branch or repo, and update when pushed too. Github pages supports custom domains as well! Whilst Github Pages supports HTTPS for github.io websites, it does not support HTTPS when using a custom domain.
However, we can use a proxy server to allow us to use a custom domain with HTTPS! Both the connection between the client and the proxy server, and the proxy server and Github will be secure.
Whilst you lose the advantage of Github’s CDN, you still have the following advantages:
- Websites are linked to a git repo, and you don’t have to worry about pulling changes and rebuilding the sites yourself.
- Storage space is saved on the server.
Add CNAME file
This is recommended to make sure that example.github.io is redirected to example.com.
Create an NGINX proxy
Point your DNS to the proxy server instead of github.io.
Add the following virtual server to your sites file:
Setting up NGINX and SSL is out of scope for this tutorial, I’m assuming you know how to configure both. If not, have a look at installing NGINX and securing NGINX with Let’s Encrypt.
Make sure you add the domain to your certificate first.
Be warned that if you have HSTS enabled, you won’t be able to go back to HTTP.