Setting up this blog
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 $ wget
the latest release from here, Linux x64root@prod $ tar -xvzf hugo.tar
root@prod $ mv hugo /usr/bin
- Set up git server
root@prod $ mkdir blog.git
root@prod $ cd blog.git && git init --bare
krishnasr@mbp $ git clone git@gitlab.com:nindalf/blog.git
krishnasr@mbp $ cd blog
krishnasr@mbp $ git remote add vps root@141.48.83.111:blog.git
krishnasr@mbp $ git remote add all git@gitlab.com:nindalf/blog.git
krishnasr@mbp $ git remote set-url --add --push all root@141.48.83.111:blog.git
krishnasr@mbp $ git remote set-url --add --push all git@gitlab.com:nindalf/blog.git
krishnasr@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/hooks
root@prod $ vim post-receive
and 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 incoming
ufw default allow outgoing
ufw allow ssh
ufw allow 'Nginx Full'
ufw enable
ufw status
- Check result is identical to this
- Set up nginx.
apt-get install nginx
vim /etc/nginx/sites-available/default
server_name blog.nindalf.com nindalf.com www.nindalf.com
- Set up certificates
add-apt-repository ppa:certbot/certbot
apt-get update
apt-get install python-certbot-nginx
certbot --nginx -d blog.nindalf.com -d nindalf.com -d www.nindalf.com
- Follow interactive tutorial
More context
Shoutout to the great tutorials on DigitalOcean!