I have started using Goatcounter for analytics after reading this LWN article called "Lightweight alternatives to Google Analytics". Goatcounter has an interesting approach to privacy in that it:
tracks sessions using a hash of the browser's user agent and IP address to identify the client without storing any personal information. The salt used to generate these hashes is rotated every 4 hours with a sliding window.
There was no Debian package for the project, so I filed a request for package and instead made a fork of the project to add a Docker image.
This page documents how Goatcounter was setup from there...
Server configuration
-
build the image from this fork
docker build -t zgoat/goatcounter . -
create volume for db:
docker volume create goatcounter -
start the server:
exec docker run --restart=unless-stopped --volume="goatcounter:/home/user/db/" --publish 127.0.0.1:8081:8080 --detach zgoat/goatcounter serve -listen :8080 -port 8080 -tls none -
apache configuration:
<VirtualHost *:80> ServerName analytics.anarc.at Redirect / https://analytics.anarc.at/ DocumentRoot /var/www/html/ </VirtualHost> <VirtualHost *:443> ServerName analytics.anarc.at Use common-letsencrypt-ssl analytics.anarc.at DocumentRoot /var/www/html/ ProxyPass /.well-known/ ! ProxyPass / http://localhost:8081/ ProxyPassReverse / http://localhost:8081/ ProxyPreserveHost on </VirtualHost> -
add
analytics.anarc.atto DNS -
create a TLS cert with LE:
certbot certonly --webroot -d analytics.anarc.at --webroot-path /var/www/html/note that goatcounter has code to do this on its own, but we avoid it to follow our existing policies and simplify things
-
create site:
docker run -it --rm --volume="goatcounter:/home/user/db/" zgoat/goatcounter create -domain analytics.anarc.at -email anarcat+rapports@anarc.at -
rebuild wiki:
ikiwiki --setup ikiwiki.setup --rebuild --verbose
Remaining issues
- the :8080 port leaks in some places, namely in the "Site config" documentation
- move to Docker Compose or podman instead of just starting the thing by hand
- this is all super janky and should be put in config management somehow
- remove "anarc.at" test site (the site is the analytics site, not the tracked site), seems like this is not possible yet
- do log parsing instead of Javascript or 1x1 images?
- compare with goaccess logs, probably in september
goatcounter monitordoesn't with sqlite
Fixed issues
cache headers are wrong (120ms!)deployed workaround in apache, reported as a bug upstreamremove self-refererdone, just a matter of configuring the URL in the settings. could this be automated too?add pixel tracking fordone, but required a patch to ikiwi (and I noticed another bug while doing it)noscriptusers
from Planet Python
via read more
No comments:
Post a Comment