Host Fathom Lite on a Laravel Forge Server
This article has been published a while ago.
If this is a technical article some information might be out of date. If something is terribly broken, let me know and I will update the article accordingly.
Fathom Lite, the predecessor to Fathom, is open source website analytics software which you can host on your own servers.
As it's written in Go, running the app on your server is as straightforward as uploading the binary, starting a daemon and pointing a webserver to it.
I recently did a spring cleaning of my servers. One task was migrating my Fathom instance to a "general" server, where I host a bunch of smallish side projects. This is a quick run down, how I did that.
1. Create a new site #
Use Forge's UI to create a new site on your existing server. Let's call it "fathom.example.com".
2. Upload the Fathom binary #
Download the latest release of Fathom Lite on GitHub and upload it to your server and the newly created "fathom.example.com" folder. (I've used good old SFTP)
If you're migrating an existing Fathom instance you can copy your existing .env
-file and fathom.db
database over too.
Make a note, on which port your Fathom instance is running (for example 9000
)
3. Start the Daemon #
Back in Forge, go to Servers →
- Command:
/home/forge/fathom.example.com/fathom server
- Folder:
/home/forge/fathom.example.com
4. Point NGINX to Fathom #
Switch to your "fathom.example.org" site in Forge and add the following block to your NGINX configuration.
Replace <your_ip_v4>
with the IP v4 address of your server and update the port accordingly.
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://<your_ip_v4>:9000;
}
5. Create a Let's Encrypt SSL Certificate #
As a final step, install a Let's Encrypt SSL certificate through Forge's UI.