Web analytics has quietly become one of the most invasive pieces of infrastructure on the modern internet. The default choice, Google Analytics 4, ships a JavaScript payload north of 45 KB, sets cookies that require a consent banner across the EU, and funnels every visitor interaction through Google’s servers. For a developer blog, a SaaS landing page, or a small company site, that trade is hard to justify: you hand over your traffic graph, your referrer data, and your users’ IP addresses in exchange for a dashboard you do not control.

Umami is the most popular open-source alternative, and for good reason. It is a single Next.js app backed by Postgres or MySQL, ships a tracking script under 2 KB, does not use cookies by default, and gives you UTM reports, referrer breakdowns, device and browser segmentation, and per-page path analytics without any third-party data flow. This article walks through deploying the current stable release (v3.5.0 at the time of writing) behind a reverse proxy on a small VPS, hardening it for production, and wiring up a website and share link so your team can actually use the data.

Why self-host analytics at all

Before the compose file, it is worth being explicit about what you gain and what you give up. Self-hosting Umami means your visitors’ IP addresses, user agents, and referrer chains never leave your server. There is no consent banner requirement in most EU interpretations because no cookies or cross-site identifiers are set by default. You own the historical data, can back it up like any other Postgres volume, and can share a read-only dashboard link with a client or stakeholder without exposing your admin panel.

What you give up is convenience. Google’s dashboards handle spikes, retention, and cross-domain tracking out of the box. Umami is single-tenant, so you need to think about database sizing if you push millions of pageviews a month, and you need to run your own backups. For a blog or product site doing under a few million pageviews per month, the operational cost is roughly one small Postgres container and a nightly dump.

The comparison with Plausible is fair to raise here. We have a separate article on self-hosting Plausible Analytics with Docker, and the choice between the two usually comes down to preference: Plausible’s UI is opinionated and easy to hand to a non-technical marketer, while Umami is fully open source under the MIT license, supports MySQL as well as Postgres, and gives you a slightly more conventional dashboard with saved reports and funnels in the newer releases. Both are dramatically lighter than GA4.

Prerequisites

You need a Linux server with Docker and the Docker Compose plugin installed. Any 1 vCPU / 1 GB VPS is enough for a blog. You also need a domain with an A record pointing at the server, and a reverse proxy that can terminate TLS and forward requests to the Umami container. We use Caddy in this guide because it handles certificates automatically, but Traefik or nginx work the same way.

You will need to decide on two hostnames before you start:

  • analytics.example.com — the Umami dashboard and the tracking script host.
  • Your existing site domain, which will load the tracking script from the analytics host.

Keeping the script on its own subdomain is optional, but it makes it easier to add a Content-Security-Policy header on your main site later without mixing concerns.

Docker Compose stack

The official Umami repository ships a docker-compose.yml that starts two services: the Umami app itself and a Postgres database. The current stable tag is v3.5.0. Save the following as docker-compose.yml on the server:

services:
  umami:
    image: ghcr.io/umami-software/umami:postgresql-v3.5.0
    restart: always
    depends_on:
      db:
        condition: service_healthy
    environment:
      DATABASE_URL: postgresql://umami:${POSTGRES_PASSWORD}@db:5432/umami
      DATABASE_TYPE: postgresql
      APP_SECRET: ${APP_SECRET}
      PORT: 3000
      HOSTNAME: 0.0.0.0
    ports:
      - "127.0.0.1:3000:3000"
    healthcheck:
      test: ["CMD-SHELL", "curl -fsS http://localhost:3000/api/heartbeat || exit 1"]
      interval: 30s
      timeout: 5s
      retries: 5

  db:
    image: postgres:17-alpine
    restart: always
    environment:
      POSTGRES_DB: umami
      POSTGRES_USER: umami
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - ./db-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U umami"]
      interval: 10s
      timeout: 5s
      retries: 5

The app image is published as postgresql-v3.5.0, which is the variant that expects a Postgres DATABASE_URL. Pinning the tag rather than using :latest keeps upgrades deliberate.

Two secrets live in a .env file next to the compose file:

POSTGRES_PASSWORD=change_me_long_random_string
APP_SECRET=another_long_random_string

Generate both with openssl rand -hex 32. The APP_SECRET is used by Umami to sign session cookies; losing it logs everyone out, so back it up next to the database dump.

Start the stack:

docker compose up -d
docker compose logs -f umami

The first boot runs the database migrations automatically. You will see Ready in followed by the listen address once it is up.

Caddy reverse proxy

The app binds to 127.0.0.1:3000 on the host, which means it is not reachable from the internet by default. Caddy sits in front, terminates TLS with an automatically renewed Let’s Encrypt certificate, and forwards to the local port:

analytics.example.com {
    reverse_proxy 127.0.0.1:3000
    encode zstd gzip
    header {
        Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
        X-Frame-Options "SAMEORIGIN"
        Referrer-Policy "strict-origin-when-cross-origin"
    }
}

Reload Caddy with systemctl reload caddy and visit https://analytics.example.com. The default admin account is admin / umami; change the password immediately from Settings → Profile after the first login.

Adding a website and installing the tracking script

Inside the Umami dashboard, click Settings → Websites → Add website. Give it a name and the root domain (for example example.com). Umami will show you a tracking snippet that looks like:

<script defer src="https://analytics.example.com/script.js" data-website-id="YOUR_WEBSITE_ID"></script>

Drop that tag into the <head> of your site. If your site is built with Astro, Next.js, or another framework that manages the document head, place the tag inside the layout component that wraps every page rather than individual pages, so you do not lose tracking on client-side navigations.

A couple of optional attributes are worth knowing about:

  • data-domains="example.com" restricts tracking to your domain and ignores hits from localhost, staging, or third-party embeds.
  • data-auto-track="false" disables automatic pageview collection so you can call umami.track() yourself for single-page apps.

Verifying that data is flowing

The simplest smoke test is to open your site in a private window, navigate to a couple of pages, then go back to the Umami dashboard. You should see a realtime visitor in the top-right corner within a few seconds.

For a programmatic check, the /api/heartbeat endpoint returns a simple success response and is what the healthcheck in the compose file uses. The /api/send endpoint is where the tracking script posts events; a POST with an empty body will return a 400 but confirms the endpoint is reachable through your reverse proxy.

If you see no data after a few minutes, check the browser console for Content-Security-Policy violations. A strict CSP on your main site that does not include analytics.example.com in script-src and connect-src will silently block the tracker.

Backups and upgrades

Because all state lives in the Postgres volume, a single nightly dump covers everything. A minimal cron entry that runs on the host looks like:

0 3 * * * cd /opt/umami && docker compose exec -T db pg_dump -U umami umami | gzip > /var/backups/umami-$(date +\%F).sql.gz

Rotate those dumps off-box with restic, borg, or plain rsync. Restoring onto a fresh server is a matter of starting the compose stack, letting migrations run, then piping the latest dump back in with docker compose exec -T db psql -U umami umami.

Upgrades follow the same pattern as any pinned container. Bump the tag in docker-compose.yml, run docker compose pull && docker compose up -d, and watch the logs for migration output. Because the tag pins a specific Umami release, you choose when to take a new version rather than having a :latest pull break your dashboard on a Monday morning.

Frequently asked questions

Does Umami use cookies? No. By default the tracking script does not set cookies and does not store personal identifiers. If you enable the optional “share a session identifier” feature for logged-in users, that becomes your responsibility to disclose.

Is Umami GDPR compliant? Out of the box, the data it collects — page path, referrer, coarse device and browser, a salted daily-rotating hash of the IP that is never stored raw — is designed to fall outside the scope of personal data under GDPR. You still need a privacy policy entry describing the analytics you run, but most self-hosters find they can drop the cookie consent banner entirely.

How much resources does it need? A single small VPS (1 vCPU, 1 GB RAM) comfortably handles a blog with tens of thousands of monthly pageviews. The bottleneck is Postgres disk I/O at very high traffic; at that point move the database to its own volume or managed instance.

Can I track multiple sites with one install? Yes. Add as many websites as you like under Settings → Websites. Each one gets its own data-website-id, and the dashboard lets you switch between them.

What about ad blockers? Any self-hosted analytics domain will be blocked by common filter lists if the hostname contains the word “analytics”. Using a neutral subdomain like stats.example.com or m.example.com reduces accidental blocking without doing anything adversarial.

How do I share a dashboard without giving admin access? Open a website, click the share icon, and enable the public share link. Umami generates a read-only URL you can send to a client or embed in an internal wiki.