Skip to content

Caddy Proxy

Caddy’s simple configuration makes it straightforward to proxy usertrax through your domain.

  1. Add to your Caddyfile

    yourdomain.com {
    # Proxy the tracking script
    handle /cvs.js {
    reverse_proxy https://usertrax.io {
    header_up Host usertrax.io
    }
    header Cache-Control "public, max-age=86400"
    }
    # Proxy the events endpoint
    handle /api/usertrax/events {
    reverse_proxy https://api.usertrax.io {
    header_up Host api.usertrax.io
    header_up X-Auth-Key {http.request.header.X-Auth-Key}
    }
    }
    # Your other site configuration...
    handle {
    file_server
    }
    }
  2. Update your HTML

    <script>
    window.usertraxConfig = {
    endpoint: "/api/usertrax/events",
    };
    </script>
    <script src="/cvs.js" data-key="YOUR_API_KEY" defer></script>
  3. Validate and reload

    Terminal-Fenster
    caddy validate
    caddy reload
  1. Visit your website
  2. Open the Network tab
  3. Confirm requests go through your domain
  • 401 Unauthorized: Ensure X-Auth-Key is forwarded with header_up
  • Caddy handles HTTPS certificates automatically — no extra SSL config needed for the upstream proxy