Self Hosting

Self hosting this site

Before the Summer I tried to self-host this site and wanted to automate the process of creating new sites based on my static site generator using some shell scripts. In the end gave up because automating the whole proess proved too complicated.

Still I was interested in running my sites on my own server, as a learning exercise. I had done most of the work already. My scripts worked well, except for the certbot automation to get the SSL certificates using letsencrypt. I had to manually edit some apache vhost files which certbot messed up by insisting on using mod_rewrite to point http to https. I don't need mod_rewrite, so want that disabled. A plain redirect is enough, and is the preferred method according to apache.

I changed my certbot command to only generate the certificate, not configure the site on the server:

sudo certbot certonly --webroot -w /var/www/robin_is -d robin.is --force-renewal --non-interactive --agree-tos --email webmaster@robin.is

I realise I could have used --apache and saved myself the -w parameter, but this way it is more explicit what is happening.

I then updated the vhost file with the correct SSL settings:

<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    ServerName robin.is
    DocumentRoot /var/www/robin_is
    ErrorLog /var/log/apache2/error.log
    CustomLog /var/log/apache2/access.log combined
    Redirect / https://www.robin.is/

    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/robin.is/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/robin.is/privkey.pem        
</VirtualHost>

I also improved my scripts generally so that adding a new site will be a straightforward task of running a set of shell scripts.

This site is now live and self-hosted on hetzner.com.

Tagged: