Skip to content
Tools and automation

Caddy analytics proxy for Reveata

2 min read · Updated · By the Reveata team

Short answerTwo handle routes in your Caddyfile serve the Reveata script and pass events on from your own domain, with your proxy secret taken from Caddy's environment. If you can't edit the pages, the replace-response plugin can insert the snippet into every HTML response.

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.js and /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

  1. Create a proxy secret in Reveata (Settings → General → Tracking code). It starts with dt_proxy_ and is shown once.
  2. Give it to Caddy as the environment variable REVEATA_PROXY_SECRET, for example with sudo systemctl edit caddy, or under the service's environment: in Docker Compose. Keep it out of the Caddyfile so it never ends up in a repository.
  3. Add the two handle routes from the Caddy install guide to your site's block, and point the snippet at them.
  4. 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.

Frequently asked questions

My app already uses /dt/ paths. What now?

Pick other paths. Avoid words like analytics, which some blockers look for.

Does a catch-all reverse_proxy to my app swallow the routes?

No. Caddy runs the most specific handle first, so /dt/event still reaches Reveata.

Where does revenue come in?

Caddy only serves pages. Connect your payment provider and pass the visitor id at checkout from your app, for example Django or Express.

See it with your own numbersReveata ties every visit and sale to the source that brought it. Add your website in a minute.
Get started
Was this page useful?
IntegrationNGINX analytics proxy and snippet injectionNGINX can insert the Reveata snippet into every HTML page with sub_filter, and proxy the script and events through two locations on your own domain. With your website's proxy secret, Reveata trusts the visitor's address NGINX forwards, so locations stay accurate.IntegrationConnect ChatGPT to your website analyticsAdd Reveata in ChatGPT's Apps and Connectors settings, or create it in developer mode with Reveata's MCP server address and OAuth. You pick which websites to share, and ChatGPT answers questions about traffic, revenue, goals and funnels with cards and charts, reading only.IntegrationConnect Claude to your analytics with MCPAdd Reveata as a connector in Claude's settings, or with one command in Claude Code, and sign in through Reveata to choose websites and permissions. Claude then reads your analytics through Reveata's MCP server and shows inline cards for overviews, rankings, realtime, goals and funnels.IntegrationDiscord alerts for website traffic and revenueCreate a webhook in a Discord channel's Integrations settings, paste its URL into a Reveata alert, and Reveata posts to that channel when the alert fires. Posts never ping anyone, even if your message contains @everyone.IntegrationGemini CLI with Reveata analyticsRun gemini mcp add with Reveata's server URL, start gemini and run /mcp auth reveata. Reveata opens in your browser to choose websites and permissions, and Gemini CLI can then answer questions about your analytics.IntegrationGitHub commits on your analytics chartConnect a GitHub repository and Reveata imports the last 90 days of commits on its default branch, then adds new ones within seconds through a push webhook. Each day with commits gets a marker on your main chart, so you can see what shipped when traffic or revenue moved.