This blog is generated by hugo, a static site generator. My flow is to write it markdown files on my laptop, commit it to a git repository and push it to the machine that’s hosting the blog you’re reading. Once the push is successful, a post-commit hook runs hugo and generates HTML pages. Nginx serves these pages.
Next, the firewall needs to be configured and optionally, SSL certificates can be provisioned using Let’s Encrypt. It’s so much better with the pretty green lock icon.
The performance of this site is great because nginx does a great job at serving files. Maintenance is hassle free because git and nginx are stable and all traffic being served is static.
The downtime I experienced is when I botched an OS upgrade that wasn’t necessary in the first place.
- Create/update DNS records for your domain
- Install hugo on prod.
root@prod $ wgetthe latest release from here, Linux x64root@prod $ tar -xvzf hugo.tarroot@prod $ mv hugo /usr/bin
- Set up git server
root@prod $ mkdir blog.gitroot@prod $ cd blog.git && git init --barekrishnasr@mbp $ git clone git@gitlab.com:nindalf/blog.gitkrishnasr@mbp $ cd blogkrishnasr@mbp $ git remote add vps root@141.48.83.111:blog.gitkrishnasr@mbp $ git remote add all git@gitlab.com:nindalf/blog.gitkrishnasr@mbp $ git remote set-url --add --push all root@141.48.83.111:blog.gitkrishnasr@mbp $ git remote set-url --add --push all git@gitlab.com:nindalf/blog.gitkrishnasr@mbp $ git push all
- Pull Git on server
root@prod $ git clone /root/blog.git/
- Set up post receive hook
root@prod $ cd /root/blog.git/hooksroot@prod $ vim post-receiveand paste in the contents from hereroot@prod $ bash post-receive- test that it’s working correctly and generating the right output in the right folder
- Set up ufw.
ufw default deny incomingufw default allow outgoingufw allow sshufw allow 'Nginx Full'ufw enableufw status- Check result is identical to this
- Set up nginx.
apt-get install nginxvim /etc/nginx/sites-available/defaultserver_name blog.nindalf.com nindalf.com www.nindalf.com
- Set up certificates
add-apt-repository ppa:certbot/certbotapt-get updateapt-get install python-certbot-nginxcertbot --nginx -d blog.nindalf.com -d nindalf.com -d www.nindalf.com- Follow interactive tutorial
More context
Shoutout to the great tutorials on DigitalOcean!