Plausible is a lightweight and open-source website analytics tool. No cookies and fully compliant with GDPR, CCPA and PECR.
Dokku is a lightweight implementation of a Platform as a Service (PaaS) that is powered by Docker. It can be thought of as a mini-Heroku.
- A working Dokku host
- PostgreSQL plugin for Dokku
- Clickhouse plugin for Dokku
- Letsencrypt plugin for SSL (optionnal)
Note: Throughout this guide, we will use the domain plausible.example.com
for demonstration purposes. Make sure to replace it with your actual domain name.
Log into your Dokku host and create the Minio 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
dokku clickhouse:create plausible -i clickhouse/clickhouse-server
# Link plugins to the main app
dokku postgres:link plausible plausible
dokku clickhouse:link plausible plausible
Configures the secret used for sessions in the dashboard.
dokku config:set plausible SECRET_KEY_BASE=$(openssl rand -base64 64 | tr -d '\n')
Configures the secret used for encrypting TOTP secrets at rest using AES256-GCM.
dokku config:set plausible TOTP_VAULT_KEY=$(openssl rand -base64 32 | tr -d '\n')
Configures the base URL to use in link generation.
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
Restricts registration of new users. Possible values are true (full restriction), false (no restriction), and invite_only (only the invited users can register).
dokku config:set plausible DISABLE_REGISTRATION=true
To enable routing for the Plausible app, we need to configure the domain. Execute the following command:
dokku domains:set plausible plausible.example.com
Begin by cloning this repository onto your local 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
Now, set up your Dokku server as a remote repository.
git remote add dokku dokku@example.com:plausible
Now, you can push the Plausible app to Dokku. Ensure you have completed this step before moving on to the next section.
git push dokku master
Lastly, let's obtain an SSL certificate from Let's Encrypt.
# Install letsencrypt plugin
dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
# Set certificate contact email
dokku letsencrypt:set plausible email you@example.com
# Generate certificate
dokku letsencrypt:enable plausible
Congratulations! Your Plausible instance is now up and running, and you can access it at 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 8000
### Invalid return
-----> Port mappings for plausible
-----> scheme host port container port
http 8000 8000
If the return is not as expected, execute this command:
dokku proxy:ports-set plausible http:80:8000
# if you also setup SSL:
dokku proxy:ports-set plausible https:443:8000
If the command's return was valid and Plausible is still not available, please create an issue in the issue tracker.
By default, Plausible will use a file called /js/plausible.js
which is blocked by most adblockers. To overcome this, you can add an Nginx configuration 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.