Urgent.News

What's breaking now, across thousands of outlets.

Tech

Bot-free self-hosted analytics with GoatCounter on NixOS

In 2016, the author removed Google Analytics from their blog to protect personal data, relying on GoAccess to analyze server logs. After a couple of years, the statistics became inaccurate due to AI scrapers inflating visitor numbers. The author then switched to GoatCounter, an open-source, privacy-friendly web analytics platform.

To filter bots more aggressively, they implemented a function that requires user interaction and use a CSS fallback for browsers with JavaScript disabled. With a single binary and an SQLite database, GoatCounter is lightweight and privacy-friendly, among alternatives like Umami, Plausible, and Rybbit. The author replaced the JavaScript client with a short function to register hits, increasing accuracy by capturing fewer than 200 human visitors daily.

Five web servers across Europe and North America serve the blog, but GoatCounter runs on only one of them. A local proxy on each server stores hits in memory and sends them to the upstream backend, ensuring accurate visitor tracking even if GoatCounter is down. The author chooses to expose the proxy endpoint on their website's domain to evade ad blockers, acknowledging that privacy-friendly services like GoatCounter are acceptable in this regard.

The author runs their servers on NixOS, a Linux distribution with built-in configuration management, and deploys GoatCounter using Colmena, a stateless deployment tool for NixOS. Each container runs a stripped-down NixOS instance, with persistent data stored on the host. A NixOS module encapsulates GoatCounter's configuration, service definition, and secrets, allowing the author to customize GoatCounter while maintaining flexibility for future changes.

Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at vincent.bernat.ch →

More in Tech

Automating Deployment with Github Actions

Deploying to a Server You Can't Reach: Building a CI/CD Pipeline with AWS SSM and OIDC From pushing code manually to building, testing, containerizing, and deploying every change automatically.

Four bugs my test suite couldn't catch

216 passing tests. A feature that was completely broken. Here is the gap between those two facts, and what I changed afterwards. The feature I am building an encrypted messenger.

Kernel prepatch 7.3-rc4

Linus Torvalds has released the 7.3-rc4 kernel prepatch. It is, unsurprisingly at this point, large: " We all know the drill by now: 'it's big, yadda yadda' ".

More from Sunday 20 September →