hexo on sub domain

Created at 2022-02-26 Updated at 2024-04-17 - 1 min. read Tag hexo, nginx

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

Table of Content

Site by Ashutosh Kumar Singh using Hexo & Random

Traveller - Developer - Foodie - Biker - Cyclist - Rider - Technocrat