hexo on sub domain
Created at 2022-08-23 Updated at 2024-11-07 - 1 min. read
I was currently exploring the way to figure out that if we can put static site generator on a sub domain or not. We can do with the help nginx and cloudflare.
First install the nginx
Update the nginx config
location /blog {
#rewrite /blog/(.*) /$1 break;
proxy_pass http://domain.com/blog;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
Setup domain on cloudflare
Set dns to the same server as all the traffic is going
Setup domain on github using CNAME. You can read about it here here
CNAME should be same as the domain name
Setup folder structure on hexo accordingly
Let’s suppose you want to setup under
www.domain.com/blog
Then you need to make following change in the _config.yl
root: “/blog/“
public_dir: public/blog