Plausible is a lightweight and open-source website analytics tool. No cookies and fully compliant with GDPR, CCPA and PECR.
Dokku is the smallest PaaS implementation you've ever seen - Docker powered mini-Heroku.
- A working Dokku host
- PostgreSQL plugin for Dokku
- Clickhouse plugin for Dokku
- Letsencrypt plugin for SSL (optionnal)
Note : We are going to use the domain plausible.example.com
for demonstration purposes. Make sure to
replace it with your own domain name.
Log onto your Dokku Host to create the Plausible app :
dokku apps:create plausible
# Install Dokku plugins
dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres
dokku plugin:install https://github.com/dokku/dokku-clickhouse.git clickhouse
# Create running plugins
dokku postgres:create plausible -I 14.6
dokku clickhouse:create plausible -i clickhouse/clickhouse-server -I 22.9.7.34
# Link plugins to the main app
dokku postgres:link plausible plausible
dokku clickhouse:link plausible plausible
dokku config:set plausible SECRET_KEY_BASE=$(openssl rand -base64 64 | tr -d '\n')
dokku config:set plausible BASE_URL=https://plausible.example.com
dokku config:set plausible MAILER_EMAIL=admin@example.com \
SMTP_HOST_ADDR=mail.example.com \
SMTP_HOST_PORT=465 \
SMTP_USER_NAME=admin@example.com \
SMTP_USER_PWD=example1234 \
SMTP_HOST_SSL_ENABLED=true
dokku config:set plausible DISABLE_REGISTRATION=true
To get the routing working, we need to apply a few settings. First we set the domain.
dokku domains:set plausible plausible.example.com
First clone this repository onto your machine.
# Via SSH
git clone git@github.com:d1ceward/plausible_on_dokku.git
# Via HTTPS
git clone https://github.com/d1ceward/plausible_on_dokku.git
git remote add dokku dokku@example.com:plausible
git push dokku master
Last but not least, we can go an grab the SSL certificate from Let's Encrypt.
# Install letsencrypt plugin
dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
# Set certificate contact email
dokku config:set --no-restart plausible DOKKU_LETSENCRYPT_EMAIL=you@example.com
# Generate certificate
dokku letsencrypt:enable plausible
Your Plausible instance should now be available on https://plausible.example.com.
If the Plausible instance is not available at the address https://plausible.example.com check the return of this command :
dokku proxy:ports plausible
### Valid return
-----> Port mappings for plausible
-----> scheme host port container port
http 80 5000
### Invalid return
-----> Port mappings for plausible
-----> scheme host port container port
http 5000 5000
If the return is not the expected one, execute this command :
dokku proxy:ports-set plausible http:80:5000
If the return of the command was valid and Plausible is still not available, feel free to fill an issue in the issue tracker.
By default, Plausible will use a file called /js/plausible.js
which is blocked by most adblockers (Adblock business lets you pay to display your ads, but privacy-focused analytics are blocked by default. Yay).
Since Plausible respects user privacy, it seems fair to collect anonymous traffic data. You can add a nginx config file: vi /home/dokku/plausible/nginx.conf.d/rewrite.conf
:
rewrite ^/js/pls.js$ /js/plausible.js last;
Rename pls.js
to whatever fits your need, and use this file name from now on.