Appendix A: Cheat Sheet
All commands come from the days of this course; the day number is in the heading. Paths, names and values as in the lab.
Files and locations
| Path | Content | Day |
|---|---|---|
~/plausible/ce |
clone of the CE repo (branch v3.2.1), Compose project
ce |
1 |
~/plausible/ce/.env |
BASE_URL, keys, ports, SMTP – permissions
600 |
1, 4, 9 |
~/plausible/ce/compose.override.yml |
ports, backup mount, Mailpit | 1, 4, 8, 9 |
~/plausible/ce/clickhouse/ |
logs.xml, low-resources.xml and
others |
1, 9 |
~/plausible/ce/clickhouse-backups.xml |
backups/allowed_path = /backups/ |
8 |
~/plausible/proxy/Caddyfile |
Caddy, mounted as a folder to /etc/caddy |
4 |
~/plausible/site |
demo site itdrills.com, snippet.html |
0, 3 |
~/plausible/pw |
besuch.js, speicher.js,
dashboard.js |
0, 3, 7 |
~/plausible/api-key |
API key for the Stats API, permissions 600 |
6 |
~/plausible/tag08 |
plausible_db.dump, env,
clickhouse/events.zip |
8 |
Volumes: ce_db-data (PostgreSQL),
ce_event-data (ClickHouse), ce_event-logs,
ce_plausible-data (exports); caddy_data,
caddy_config (Day 1, 4, 8).
Ports and addresses
| Address | What | Day |
|---|---|---|
http://itdrills.com:8080 |
demo site (nginx, container site) |
0 |
127.0.0.1:8000 |
Plausible (until Day 3, :8000 reachable from
outside) |
1, 4 |
https://plausible.lab |
dashboard and API via Caddy | 4 |
https://itdrills.com |
demo site, /js/script.js and /api/event
via Caddy |
4 |
127.0.0.1:8025 |
Mailpit (web UI and API) | 9 |
5432, 8123, 9000 |
PostgreSQL, ClickHouse – only in the Compose network | 1 |
Hosts entries (Day 0)
# on argo
printf '127.0.0.1 plausible.lab itdrills.com\n::1 plausible.lab itdrills.com\n' \
| sudo tee -a /etc/hosts
getent ahosts itdrills.com | awk '{print $1}' | sort -u# on your machine, file /etc/hosts
172.16.0.182 plausible.lab itdrills.com
.env (Day 1, 4, 9)
| Variable | Value in the lab | Note |
|---|---|---|
BASE_URL |
https://plausible.lab |
ends up in the snippet; until Day 3 http://…:8000 |
SECRET_KEY_BASE |
openssl rand -base64 48 |
sessions, hash of the API keys |
TOTP_VAULT_KEY |
openssl rand -base64 32 |
encrypts 2FA secrets |
HTTP_PORT |
8000 |
port inside the container |
DISABLE_REGISTRATION |
true |
default invite_only, false = open |
MAILER_EMAIL, MAILER_NAME |
[email protected], Plausible Labor |
sender |
SMTP_HOST_ADDR, SMTP_HOST_PORT |
mailpit, 1025 |
real server: 587/465 |
SMTP_USER_NAME, SMTP_USER_PWD |
– | credentials at the mail provider |
SMTP_HOST_SSL_ENABLED |
false |
no TLS in the lab |
Only in the Enterprise Note: HTTPS_PORT=443 (Plausible
fetches Let’s Encrypt certificates itself).
Stack (Day 1, 8, 9)
# on argo
git clone -q -b v3.2.1 --single-branch \
https://github.com/plausible/community-edition ce
docker compose up -d --quiet-pull 2>&1 | tail -2
until curl -sf http://plausible.lab:8000/api/health >/dev/null; do sleep 5; done
docker compose up -d 2>&1 | tail -1 # after every change to .env
docker compose ps --format '{{.Service}}\t{{.Status}}'
docker compose images plausible --format json | jq -r '.[0].Tag'
docker compose exec -T plausible env | grep '^SMTP_HOST' | sort
docker compose up -d --wait plausible_db plausible_events_db # only the DBs (restore)
docker compose stop plausible_events_db 2>&1 | tail -1
docker compose start plausible_events_db 2>&1 | tail -1
docker compose logs plausible --since 10m --no-log-prefix 2>&1 | grep -c '\[error\]'
docker stats --no-stream --format '{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}'
git fetch -q origin v3.2.1 && git switch -q -c v3.2.1 FETCH_HEAD # upgradedocker compose restart does not pick up
a changed .env (Day 1).
Opening the databases (Day 1, 2)
# on argo
cd ~/plausible/ce
docker compose exec -T plausible_db psql -U postgres -d plausible_db -tAc "select …"
docker compose exec -T plausible_events_db clickhouse-client -d plausible_events_db \
--query "select … format TSV"
docker compose exec -T plausible bin/plausible rpc 'IO.puts("…")' # live Elixir-T is required when no terminal is attached (scripts,
redirects with <).
PostgreSQL: tables and queries
| Table | Content | Day |
|---|---|---|
users, sites |
users, sites (allowed_event_props,
public) |
1, 5, 7 |
tracker_script_configuration |
script identifier pa-…, checkboxes |
1 |
goals |
event_name, page_path,
scroll_threshold |
5 |
shield_rules_ip,
shield_rules_hostname |
shields (deny or allow) |
7 |
shared_links, salts,
api_keys |
shared links, salt, key hash | 7, 8 |
schema_migrations |
migration state | 9 |
select id from tracker_script_configuration;
select id, event_name, page_path, scroll_threshold from goals order by id;
select allowed_event_props from sites;
select inet, description, action from shield_rules_ip;
select hostname, hostname_pattern, action from shield_rules_hostname;
select slug from shared_links where name = 'Kunde';
select id, length(salt), inserted_at from salts order by id;
select name, key_prefix, length(key_hash) from api_keys;
select count(*) from schema_migrations;ClickHouse: queries (Day 2–7, 10)
-- pageviews and visitors since a point in time
select count(), uniqExact(user_id) from events_v2
where name = 'pageview' and timestamp >= '2026-11-21 08:00:00';
-- sessions: collapse intermediate states with FINAL
select entry_page, exit_page, pageviews from sessions_v2 final;
-- source, campaign
select entry_page, source, referrer_source, utm_source, utm_campaign
from sessions_v2 final order by start;
-- click events with target URL
select name, meta.value from events_v2 where name not in ('pageview', 'engagement');
-- event names are case-sensitive
select name, count() from events_v2 where lower(name) = 'signup' group by name;
-- custom property
select meta.value[indexOf(meta.key, 'plan')] as plan, count()
from events_v2 where has(meta.key, 'plan') group by plan;
-- conversions like a goal
select uniqExactIf(user_id, name = 'Signup') as signup,
uniqExactIf(user_id, name = 'engagement' and pathname = '/books/sops/'
and scroll_depth >= 75) as scroll75
from events_v2;
-- funnel replacement
select level, count() from (select user_id, windowFunnel(3600)(timestamp,
name = 'pageview' and pathname = '/books/',
name = 'pageview' and pathname = '/books/sops/', name = 'Signup') as level
from events_v2 group by user_id) group by level order by level;
-- empty source as in the dashboard
select if(source = '', 'Direct / None', source) as q, uniqExact(user_id)
from events_v2 group by q;
-- space per table
select database, table, formatReadableSize(sum(bytes_on_disk)) from system.parts
where active group by database, table order by sum(bytes_on_disk) desc;
-- backups and restores since the last start
select name, status, formatReadableSize(total_size) from system.backups;
truncate table events_v2; -- deletes all events of all sites (Day 2)Events by hand (Day 2, 4, 10)
# on argo
UA="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0"
curl -s -i -X POST https://itdrills.com/api/event -H "User-Agent: $UA" \
-H 'X-Forwarded-For: 203.0.113.10' -H 'Content-Type: application/json' \
-d '{"name":"pageview","url":"https://itdrills.com/books/","domain":"itdrills.com"}' \
| grep -iE '^HTTP|dropped'
curl -s http://plausible.lab:8000/api/health; echo # from Day 4: https://plausible.lab| Response | Meaning | Day |
|---|---|---|
202 without x-plausible-dropped |
accepted, in events_v2 after ~3 s |
2 |
202 with x-plausible-dropped: 1 |
dropped: foreign domain, bot, shield | 2, 7 |
400 {"errors":…} |
required field missing (domain, url) |
2 |
404 from the Plausible server on
/js/pa-….js |
script identifier does not exist | 10 |
www. is stripped, the default curl user
agent counts, Googlebot and HeadlessChrome do
not (Day 2, 3).
Snippet (Day 1, 3, 4)
<script async src="/js/script.js"></script>
<script>
window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(…
plausible.init({endpoint: "/api/event"})
</script>Embedded directly:
src="https://plausible.lab/js/pa-<id>.js" and
plausible.init(). Custom events:
plausible('Signup', {props: {plan: 'pro'}}). Exclude
yourself: localStorage.plausible_ignore = 'true' (Day
3).
# on argo
sed -i '/^<\/head>$/e cat snippet.html' index.html # before </head> (Day 3)
sed -n '/script.js/,/<\/script>/p' ../index.html > snippet # copy (Day 10)
sed -i "/<\/title>/r $HOME/plausible/tag10/snippet" index.html # insert (Day 10)Visits with Playwright (Day 0, 3, 4, 5)
# on argo
cd ~/plausible/pw
UA="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)"
UA="$UA Chrome/140.0.0.0 Safari/537.36"
docker run --rm --network host --user "$(id -u):$(id -g)" -e HOME=/tmp -e ECHT=1 \
-e UA="$UA" -e IP=203.0.113.61 -v ~/plausible/pw:/pw -w /pw \
mcr.microsoft.com/playwright:v1.65.0-noble \
node besuch.js https://itdrills.com/books/sops/ 'klick:#pro' | tail -1besuch.js |
Effect |
|---|---|
ECHT=1 |
--disable-blink-features=AutomationControlled
(otherwise webdriver) |
UA=… |
Chrome user agent instead of HeadlessChrome |
IP=… |
X-Forwarded-For to /api/event (via
page.route, without CORS) |
REFERER=…, BLOCK=plausible |
set the referrer, simulate an ad blocker |
klick:<selector>, ignorieren |
click, set plausible_ignore |
scrollen, wegklicken |
scroll to the end, switch tabs (sends engagement) |
Output: -> event sent,
<- 202 gezählt|verworfen (counted/dropped),
blockiert … (blocked), Ignoring Event: ….
speicher.js <url> shows cookies, localStorage,
sessionStorage (Day 7).
Caddy (Day 4, 10)
{
servers {
trusted_proxies static 127.0.0.1/8 ::1
}
}
plausible.lab {
tls internal
reverse_proxy 127.0.0.1:8000
}
itdrills.com {
tls internal
handle /js/script.js {
rewrite * /js/pa--JsuJYgBCST1JOUHGfKkS.js
reverse_proxy 127.0.0.1:8000 {
header_up Host plausible.lab
}
}
handle /api/event {
reverse_proxy 127.0.0.1:8000 {
header_up Host plausible.lab
}
}
handle {
reverse_proxy 127.0.0.1:8080
}
}
# on argo
docker exec caddy caddy validate --config /etc/caddy/Caddyfile 2>&1 | tail -1
docker exec caddy caddy reload --config /etc/caddy/Caddyfile 2>/dev/null; echo "rc=$?"
docker cp caddy:/data/caddy/pki/authorities/local/root.crt /tmp/caddy-root.crt
sudo cp /tmp/caddy-root.crt /usr/local/share/ca-certificates/caddy-lab.crt
sudo update-ca-certificates
docker exec caddy ls /data/caddy/certificates/local
curl -s -o /dev/null -w 'LAN %{http_code}\n' --resolve plausible.lab:443:172.16.0.182 \
https://plausible.lab/api/healthIndent with tabs. Access restriction for the dashboard:
@fremd not remote_ip 127.0.0.1/8 ::1 and
respond @fremd 403 (Day 4, Challenge).
Stats API v2 (Day 6)
# on argo
K=$(cat ~/plausible/api-key)
Q='{"site_id":"itdrills.com","date_range":"day","metrics":["visitors"],
"dimensions":["event:page"],"filters":[["is","event:goal",["Signup"]]],
"order_by":[["visitors","desc"]]}'
curl -s -H "Authorization: Bearer $K" -H 'Content-Type: application/json' \
https://plausible.lab/api/v2/query -d "$Q" \
| jq -r '.results[] | "\(.metrics[0])\t\(.dimensions[0])"'| Field | Values from the book |
|---|---|
metrics |
visitors, visits, pageviews,
events |
bounce_rate (percent), visit_duration
(seconds) |
|
date_range |
"day", "all",
["2026-11-20","2026-11-20"] |
dimensions |
event:page, event:goal,
event:props:plan |
visit:source, time:hour |
|
filters |
[["is", "event:goal", ["Signup"]]], several = AND |
operators is, is_not,
contains, matches |
Shields and sharing (Day 7)
- Site settings → Shields → IP addresses / Hostnames (also Countries, Pages). New rules take effect after ≤ 30 s, deletions via SQL only after a restart.
- The first hostname rule turns it into an allowlist;
*.itdrills.comdoes not coveritdrills.comitself. - Visibility → Add shared link:
https://plausible.lab/share/itdrills.com?auth=….
Backing up and restoring (Day 8, 9)
# on argo
cd ~/plausible/ce
docker compose exec -T plausible_db pg_dump -U postgres -Fc plausible_db \
> ~/plausible/tag08/plausible_db.dump
docker compose exec -T plausible_db pg_restore --list \
< ~/plausible/tag08/plausible_db.dump | grep -c 'TABLE DATA'
docker compose exec -T plausible_events_db clickhouse-client --query \
"BACKUP DATABASE plausible_events_db TO File('/backups/events.zip')"
install -m 600 ~/plausible/ce/.env ~/plausible/tag08/env
sudo install -d -o 101 -g 101 -m 750 ~/plausible/tag08/clickhouse
# restore onto a fresh stack: start only the DBs first
docker compose exec -T plausible_db pg_restore -U postgres --create -d postgres \
< ~/plausible/tag08/plausible_db.dump
docker compose exec -T plausible_events_db clickhouse-client --query \
"RESTORE DATABASE plausible_events_db FROM File('/backups/events.zip')"
# second restore: stop Plausible, then
docker compose exec -T plausible_events_db clickhouse-client --query \
"DROP DATABASE plausible_events_db SYNC"
docker compose exec -T plausible_db psql -U postgres -q \
-c 'drop database plausible_db with (force)'Override for the backup path (Day 8):
services:
plausible_events_db:
volumes:
- ./clickhouse-backups.xml:/etc/clickhouse-server/config.d/backups.xml:ro
- ~/plausible/tag08/clickhouse:/backupsMail (Day 9)
# on argo
curl -s http://127.0.0.1:8025/api/v1/messages \
| jq -r '.messages[] | "\(.From.Address) -> \(.To[0].Address): \(.Subject)"'“Forgot password” via curl needs the
_csrf_token from the page and the cookie
(-c/-b).
Never without thinking
- Losing or regenerating
.env– API keys, 2FA and sessions depend on it. - Running
docker compose restartafter changing.envand believing it takes effect. - Editing
compose.ymlof the CE repo instead ofcompose.override.yml. - Publishing the Plausible port bypassing Caddy
(
8000:8000instead of127.0.0.1:8000:8000). - Deleting
trusted_proxies“because it isn’t documented anywhere”. truncate table events_v2in production without a backup.- Going back after an upgrade with
git switchinstead of restoring the backup. - Creating a second goal for a misspelled event name.
Error patterns
| Symptom | Cause | Day |
|---|---|---|
| No event from Playwright, no message | navigator.webdriver – ECHT=1 |
3 |
<- 202 verworfen (dropped) from Playwright |
user agent HeadlessChrome |
3 |
| Browser “(not set)” | UA detection > 200 ms | 3 |
Ignoring Event: localhost |
request via localhost |
3 |
Ignoring Event: localStorage flag |
plausible_ignore set |
3 |
Variable from .env missing in the container |
restart instead of up -d |
1, 9 |
curl rc=60 |
lab CA not in the trust store | 4 |
rc=7 on :8000 from outside |
intended: port only on 127.0.0.1 |
4 |
Many pageviews, one visitor (3 1) |
trusted_proxies missing |
4, 10 |
blockiert https://plausible.lab/js/pa-… |
snippet embedded directly | 4, 10 |
/js/script.js → 404 |
wrong pa-… identifier in the Caddyfile |
10 |
| Event counted, goal stays at 0 | event name spelled differently (signup) |
5, 10 |
All visits 202 verworfen |
hostname allowlist without itdrills.com |
7, 10 |
{"error":"#/filters/0: Invalid filter …"} |
wrong dimension (event:goals) |
6 |
401, Invalid API key… |
wrong key, new SECRET_KEY_BASE |
6, 8, 10 |
Mua.TransportError) non-existing domain |
no SMTP configured | 6 |
Dates Conflict on CSV import |
in the lab even without overlap | 6 |
Path '/backups/…' is not allowed for backups |
allowed_path missing |
8 |
Code: 608 …
already contains some data |
second RESTORE into full tables |
8 |
Health {"clickhouse":"error"} 500 |
ClickHouse down, events lost | 9, 10 |
WriteBuffer terminating in the log |
buffer discarded, ClickHouse gone | 9 |
Hundreds of [error] Ch.Connection |
ClickHouse restart, stops afterwards | 9 |
| Old version starts, schema is newer | migrations only run forwards | 9 |
Versions
| Component | Version | From day |
|---|---|---|
| Ubuntu (VM) | 24.04.5 LTS | 0 |
| Docker Engine / Compose | 29.10.0 / v5.8.0 | 0 |
| nginx (demo site) | 1.30.7-alpine | 0 |
| Playwright (image and npm) | v1.65.0-noble / 1.65.0 | 0 |
| Plausible CE | v3.2.1 (trial: v3.1.0) | 1 |
| PostgreSQL | 16-alpine | 1 |
| ClickHouse | 24.12-alpine | 1 |
| Caddy | 2.11.9-alpine | 4 |
| Mailpit | v1.33.0 | 9 |
Documentation
- Plausible CE: github.com/plausible/community-edition (README and wiki)
- Plausible: plausible.io/docs (Stats API, Goals, Shields, Proxy)
- ClickHouse: clickhouse.com/docs (BACKUP/RESTORE, windowFunnel)
- PostgreSQL: postgresql.org/docs (pg_dump, pg_restore)
- Caddy: caddyserver.com/docs (reverse_proxy, trusted_proxies, tls internal)
- Playwright: playwright.dev
- Mailpit: mailpit.axllent.org