Aaron Ward

Server Notes

I've been using DigitalOcean for my hosting and DNS. I have a little experience with Heroku and Microsoft Azure too, but so far I like DigitalOcean the best. They all work but DigitalOcean has my favorite web interface, it has nice backup features and it's affordable. When you're just starting out, their $4.99/month tier is good enough for most projects. For this site and its supporting services, I found that sometimes my memory usage could spike causing services to go down. Since upgrading to the $9.99/month tier I haven't had any issues.

DNS

To use my custom .info domain, I updated my domain registrar to point to DigitalOcean nameservers. I personally use Namecheap and found this guide helpful.

Email

For now I'm using a free email alias service called ImprovMX. This allows me to send emails with my custom .info domain from a free Gmail account. This guide explains how to set things up.

Ghost

I use Ghost as a headless Content Management System. It was the first thing I set up, which was lucky because it made it easy to set up SSL for the other subdomains that I eventually registered on the same Droplet. It's really easy to set up using these instructions.
If you plan on using a Handlebars based Ghost template you can use your primary domain but since I was reserving @ & www for my front end, I pointed a subdomain to Ghost. To make the CMS headless you should go to https://[your subdomain]/ghost/ then Settings → General → "Make this blog private."

Gatsby

A popular way to host a Gatsby project is to use Netlify. After using it, I can understand why. It's free[1] and be configured to build whenever a change is submitted via GitHub or Ghost[2] via webhooks. I had initially planned to serve my site from the same DigitalOcean droplet that hosts my instance of Ghost, but Netlify is more convenient for now.

To register my custom domain with Netlify, I linked to an A record that I set up on DigitalOcean.

Plausible

Installation

To get set up with Plausible, you can follow the docker-compose based guide here.

I was new to docker so I ran into a few snags. These commands helped me to understand what was going on.

docker ps to get the process status
docker images lists docker images
docker volume ls lists docker volume
docker container ls lists docker container

I had to upgrade my droplet from 1GB RAM to 2GB to get Plausible to install. After installation, I was able to go back to 1GB of RAM and still have everything work. This should be fixed by now but I also had to revert this change to get the install to complete.

Geo Database

Setting up GeoLite2 involved downloading the free geo database to my server and updating plausible-variables with GEOLITE2_COUNTRY_DB=/countries/GeoLite2-Country.mmdb. I also had to add COPY countries /countries to my dockerfile.

Integration

In order to integrate Plausible into the front end, I slightly modified a version of gatsby-plugin-plausible to work with a self-hosted version of Plausible. You can find my plugin here. This plugin only logs when in a production environment so you don't pollute your logs while you're developing your site.

Coral Talk

Installation & Integration

The official documentation includes an easy to follow docker-compose based installation guide. For a Gatsby specific client integration, you can reference the component I created here. While in development, keep in mind that the metadata from your CMS won't be crawled by Talk but once you publish your site, everything should work.

If you're trying to pass fonts to the Talk iframe while styling the front end, you'll have to use Access-Control-Allow-Origin headers on the fonts you serve from your primary domain to allow access on your Talk domain. You can reference my example here.

Social Logins

To make it more likely that visitors will comment, I thought it would be worthwhile to set up social logins. Talk supports login with Google and Facebook. Probably the trickest part of this integration is coming up with a privacy policy, since now you'll be taking on the responsibility of handling user data.

Reverse Proxy

To make the Plausible and Talk servers accessible under their own subdomains I used Nginx and followed this guide.

Basically you start by adding a new A record for your subdomain on DigitalOcean. Then, while logged in your droplet as ghost-mgr sudo -i -u ghost-mgr, you switch to your subdomain url ghost config url https://subdomain a record and setup SSL ghost setup nginx ssl after that, you can switch back to your main domain ghost config url https://main domain a record. Now you can edit the generated Nginx config files vim /var/www/ghost/system/files/[~.ssl.conf/~.conf] and set up the reverse proxy.

/var/www/ghost/system/files/[~.conf]

server {
    server_name [subdomain a record];

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:[port];
    }

    location ~ /.well-known {
        allow all;
    }
}

/var/www/ghost/system/files/[~.ssl.conf]

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name [subdomain a record];

    ssl_certificate /etc/letsencrypt/[subdomain a record]/fullchain.cer;
    ssl_certificate_key /etc/letsencrypt/[subdomain a record]/[subdomain a record].key;

    location ~ /.well-known {
        allow all;
    }

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:[port];
    }
}

In my case, I also added a location /dashboard redirect as a vanity URL path for my public facing analytics dashboard.

To finish, run sudo nginx -t to test your update and if all goes well, nginx -s reload to make your changes live.

I also followed this guide to make my port available. Enter ufw allow [port] and verify the port is allowed with ufw status numbered. If you want to undo the change, you can use ufw delete allow [port].

Systemd Services

To ensure the Plausible and Talk web server keep running whenever the system reboots, we should use a process manager.

For Plausible, create a new file called /etc/systemd/system/plausible.service with the following contents.

plausible.service

[Unit]
Description=Starts the Plausible server
Requires=network.target
After=network.target

[Service]
Type=simple
User=root
Restart=always
RestartSec=3
WorkingDirectory=/root/analytics
ExecStart=/usr/local/bin/docker-compose up -d plausible

[Install]
WantedBy=multi-user.target

Likewise for Talk, create the following file:

/etc/systemd/system/talk.service

[Unit]
Description=Starts the Talk server
Requires=network.target
After=network.target

[Service]
Type=simple
User=root
Restart=always
RestartSec=3
WorkingDirectory=/root/talk
ExecStart=/usr/local/bin/docker-compose up -d

[Install]
WantedBy=multi-user.target

Reload the Systemd configuration & enable our services so that Plausible and Talk are automatically started whenever the system boots.
systemctl daemon-reload
systemctl enable plausible
systemctl enable talk


  1. It's free up to 300 monthly build minutes. The pricing page has details for other tiers. ↩︎

  2. The starter project I used included a netlify.toml file that streamlines deployment. ↩︎