Caddy's short configuration and automatic HTTPS make it a popular front for self-hosted apps. A few lines are enough to put Reveata on your own domain, which keeps the script out of reach of most ad-blocker lists and keeps visitor locations accurate.
What you get
- A first-party script and event endpoint, such as
/dt/script.jsand/dt/event. - The visitor's real address forwarded with your proxy secret, so countries, exclusions and per-visitor limits work.
- Snippet injection for pages you can't edit, with an optional plugin.
Proxying the script and events
- Create a proxy secret in Reveata (Settings → General → Tracking code). It starts with
dt_proxy_and is shown once. - Give it to Caddy as the environment variable
REVEATA_PROXY_SECRET, for example withsudo systemctl edit caddy, or under the service'senvironment:in Docker Compose. Keep it out of the Caddyfile so it never ends up in a repository. - Add the two
handleroutes from the Caddy install guide to your site's block, and point the snippet at them. - Restart Caddy so it reads the new environment; later Caddyfile changes need only
caddy reload.
Caddy sets X-Forwarded-For itself. Don't forget header_up Host {upstream_hostport}: without it, Caddy sends your own host name and Reveata can't answer. The directive is described in Caddy's reverse_proxy docs (opens in a new tab).
Behind a load balancer or CDN
{client_ip} is the load balancer's address until you trust it. Add its published ranges under trusted_proxies in the global options; with Cloudflare, also add client_ip_headers CF-Connecting-IP.
Injecting the snippet
If you can edit the pages, paste the snippet in the layout every page uses. If you can't, build Caddy with the replace-response plugin (xcaddy build --with github.com/caddyserver/replace-response), which isn't in the standard build, and replace </head> in HTML responses. header_up -Accept-Encoding asks your app for uncompressed pages so the plugin can read them.
Checking it works
Open /dt/script.js on your site, then find /dt/event in the browser's Network tab: the x-reveata-proxy header says trusted when the secret was accepted, and Realtime shows your own city. proxy_secret_invalid means the secret is missing or wrong; check it with sudo systemctl show caddy -p Environment.