I wanted to use custom domain for Github Pages, with HTTPS enabled using my own certs(not a CloudFlare one).
According to Github Pages instruction, the first part is done by setting up a CNAME both in project root folder and DNS, but this way HTTPS is not supported: https://example.github.io with custom domain example.com is only accessible in http://example.com, https://example.com won't work.
Thus I'm thinking of nginx reverse proxy: remove CNAME file and DNS setting, let 3 links co-exist, redirect http custom domain to https one, forward requests of https one to github.io address.
However, result is not perfect: homepage and css(in /css/main.css !) are loaded correctly, all links are displayed normally, but click them will result in 301 and redirected to github.io.
My nginx version is 1.9.5, configuration for port 80:
server {
listen 80;
server_name myblog.com;
return 301 https://$server_name$request_uri;
}
for 443:
server {
listen 443 ssl http2;
server_name myblog.com;
ssl_certificate /etc/nginx/ssl/orz.crt;
ssl_certificate_key /etc/nginx/ssl/orz.key;
add_header Strict-Transport-Security max-age=31536000;
location / {
proxy_pass https://example.github.io;
proxy_set_header Host example.github.io;
}
}