Skip to content

neodyland/traefik-umami-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Traefik → Umami Middleware (Axum)

Note

This project is vibe-coded via codex. @googlefan256 reviewed most code before merge and this code is running on prod environment but be careful when running on your own resource.

Most of the README below is written by codex.

Lightweight(~50MB) & high performance(axum) container to be used with Traefik to emit access events to Umami.

LICENSE: MIT

Features

  • Built with axum, tokio, and anyhow.
  • Captures request metadata (IP, method, user-agent, host, path, referrer).
  • Sends Umami event payloads to a configurable Umami API endpoint.
  • Returns 204 immediately and reports to Umami asynchronously.
  • Automatically excludes common static-asset paths and framework-internal endpoints (Next.js/Nuxt/Astro/SvelteKit/Vite, etc.) from tracking.

Environment variables

Variable Required Default Description
LISTEN_ADDR No 0.0.0.0:8080 HTTP bind address.
UMAMI_ENDPOINT Yes - Umami event endpoint (for example https://umami.example.com/api/send).
UMAMI_WEBSITE_ID Yes - Website ID from Umami.
EVENT_NAME No traefik_access Umami event name.
REQUEST_TIMEOUT_SECS No 3 Timeout for Umami API calls.

Run locally

export UMAMI_ENDPOINT="https://umami.example.com/api/send"
export UMAMI_WEBSITE_ID="YOUR_WEBSITE_ID"
cargo run

Run via docker

# both arm64 and amd64 are supported
export UMAMI_ENDPOINT="https://umami.example.com/api/send"
export UMAMI_WEBSITE_ID="YOUR_WEBSITE_ID"
docker run -it --rm --name traefik-umami-middleware neodyland/traefik-umami-middleware:latest

Traefik example (forwardAuth)

http:
  middlewares:
    umami-tracker:
      forwardAuth:
        address: "http://traefik-umami-middleware:8080"
        trustForwardHeader: true
  routers:
    app:
      rule: "Host(`app.example.com`)"
      service: app-service
      middlewares:
        - umami-tracker

In this mode, Traefik forwards request context headers (X-Forwarded-*) that are transformed into Umami event payloads.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors