1. Prepare the Server
On Ubuntu 24.04, secure the server and install Docker. Point an A record such as stats.example.com at it and allow ports 80 and 443.
2. Get the Compose File and Set Secrets
mkdir ~/umami && cd ~/umami wget https://raw.githubusercontent.com/umami-software/umami/master/docker-compose.yml echo "APP_SECRET=$(openssl rand -hex 32)" > .env openssl rand -hex 32 # for TWO_FACTOR_ENCRYPTION_KEY below nano docker-compose.yml
In docker-compose.yml, change three things:
- Replace
replace-me-with-a-64-character-hex-stringwith the second random value, for two-factor sign-in. - Change the database password from
umamiin both places:POSTGRES_PASSWORDand the password insideDATABASE_URL(postgresql://umami:PASSWORD@db:5432/umami). Use letters and digits only, so the URL needs no escaping. - Bind the app to the server itself, so only Caddy reaches it:
"127.0.0.1:3000:3000"in place of"3000:3000". Docker would otherwise open the port past ufw, as explained in why ufw does not block Docker ports.
docker compose up -d docker compose ps # both services should be healthy
3. Add HTTPS With Caddy
sudo apt install -y caddy
sudo tee /etc/caddy/Caddyfile >/dev/null <<'EOF'
stats.example.com {
reverse_proxy 127.0.0.1:3000
}
EOF
sudo systemctl reload caddy4. Sign In and Track a Site
- Open
https://stats.example.comand sign in asadminwith the passwordumami. Umami asks you to set a new password before you continue. - Add your website with its domain.
- Edit the website, copy the code under Tracking code and paste it into the
<head>of every page. On a Next.js site, use thenext/scriptcomponent. - Visit your site: the visit appears on the Umami dashboard straight away.
Backups and Updates
Everything Umami records is in its PostgreSQL database. Dump it nightly and copy the file off the server, as in backing up a database to S3:
cd ~/umami mkdir -p ~/backups docker compose exec -T db pg_dump -U umami umami | gzip > ~/backups/umami-$(date +%F).sql.gz
Update with docker compose pull && docker compose up -d after a backup and a look at the release notes. The same server can host more of your tools, such as Uptime Kuma for monitoring.