Upgraded to version 2.0 following instructions here Aug 15, 2023
Β
The latent docker image issue was gone, simply using the latest release tag
plausible@latest
in Dockerfile would workCity level data is automatically downloaded. Set an env variable
MAXMIND_LICENSE_KEY
before app startup if you need itRan into some Clickhouse connection issue during app boot up, resolved by setting CLICKHOUSE_DATABASE_URL (plausible_events_db) and DATABASE_URL (plausible_db) with their ip v4 addresses
Β
Plausible.io is an open source alternative to Google Analytics created by some inspiring indie devs. Its vision to be transparent about how website traffic data is handled really separates it apart from other proprietary alternatives. I first came across it from above Indie Hacker Podcast and managed to get it hosted on an EC2 container. However, the AWS bills increased too fast that I had to switch to Fly.io for cheaper hosting.
How
By following the rule of βDonβt reinvent the wheelβ, I found that similar need was already addressed by others, well summarized in a blog post plus a code repository.
I basically went through the same process by following the instructions, besides fixing some issues related to outdated information. In addition, I also enabled the available in recent release.
City level location data
Updated Nov 23, 2021
Problems
Plausible deployment failures
- Caused by under provisioning
Solution:
fly scale memory 1024
release_command
infly.toml
failed to create and migrate DB- Update
fly.toml
- Deploy
- Run the migration command
I wound up deploying once to create the DB, then again to migrate the DB when the first deploy failed to run.
Solution:
- release_command = 'db migrate' + release_command = 'db createdb'
fly ssh console entrypoint.sh db migrate
The latest docker image release are behind development (i.e. master
branch)
- DB connection issue. Fly.io does all internal networking over IPv6, and that required a Change to how phoenix apps are built. The phx generators have been updated, but it required a PR for plausible.
- The other issue is that I wanted to
force_ssl
, but thatβs a compile-time configuration
config :plausible, PlausibleWeb.Endpoint, force_ssl: [rewrite_on: [:x_forwarded_proto]],
- Missing features like region/city level information
Solution:
- Fork
- Copy
fly.toml
from theplausible
directory to the forkedanalytics
directory
- Deploy change
fly deploy
Guides
Prerequisite
Make sure
fly
CLI is installed and is logged in to be able to run other commands brew install fly fly auth login
Postgres DB
fly pg create plausible-db
Clickhouse
cd clickhouse
fly apps create plausible_clickhouse
fly vol create plausible_clickhouse_data
fly deploy
Plausible (Analytics)
cd plausible
fly apps create plausible
fly pg attach plausible-db
- Set secrets
openssl rand -base64 64 | tr -d '\n' ; echo fly secrets set SECRET_KEY_BASE=<FROM ABOVE> \ ADMIN_USER_NAME=<username> \ ADMIN_USER_EMAIL=<email> \ ADMIN_USER_PWD=<password> \ BASE_URL=<host_url>
fly scale memory 1024
scale up to avoid under provision
Add Cities Level Data
cd plausible
- Create a volume for geo data
fly vol create myapp_data
# fly.toml [mounts] source="myapp_data" destination="/data"
- Download
geonames.csv
&geolite2-city.mmdb
to the container fly ssh console
cd /data
# geonames.csv wget https://s3.eu-central-1.wasabisys.com/plausible-application/geonames.csv # geolite2-city.mmdb export MAXMIND_LICENSE_KEY=LNpsJCCKPis6XvBP # replace this with your own wget "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=${MAXMIND_LICENSE_KEY}&suffix=tar.gz" -O geolite2-city.mmdb.gz gunzip geolite2-city.mmdb.gz
- Set Secrets to the data location
fly secrets set IP_GEOLOCATION_DB='/data/geolite2-city.mmdb' GEONAMES_SOURCE_FILE='/data/geonames.csv'
DNS Entries / SSL
fly certs create <BASE_URL>
Β
Β
Note:
Self host on EC2 guide
- Bootstrap an EC2 Ubuntu instance (e.g. t2.medium, > 2G RAM) w/ security group inbound rules configured
- HTTP 80
- HTTPS 443
- Install Nginx https://ubuntu.com/tutorials/install-and-configure-nginx
- Install Docker & Docker Compose for Ubuntu
- Installing Certbot according to the EFF https://certbot.eff.org/instructions?ws=nginx&os=ubuntufocal
- Continue with https://plausible.io/docs/self-hosting#up-and-running
Β