Support/Proxy Guides
Proxy Guides

Proxying Flowsery Analytics with Caddy

Route Flowsery Analytics through Caddy to prevent adblocker interference and capture more accurate visitor data. Caddy's straightforward configuration makes this particularly easy to set up.

1. Core Caddy Configuration

Add the following directives to your Caddyfile:

Text
your_domain.com {
    # Proxy the analytics script
    handle /js/main.js {
        reverse_proxy https://analytics.flowsery.com {
            header_up Host {upstream_hostport}
            header_up X-Real-IP {remote_host}
            header_up X-Forwarded-For {remote_host}
            header_up X-Forwarded-Proto {scheme}
        }
 
        # Cache the script for 1 year
        header Cache-Control "public, max-age=31536000"
        header Expires "1y"
    }
 
    # Proxy the event collection endpoint + forward real visitor IP
    handle /api/track {
        reverse_proxy https://analytics.flowsery.com {
            header_up Host {upstream_hostport}
 
            # CRITICAL: Flowsery reads this header as the real visitor IP.
            # Without it, every visitor resolves to your server's region.
            # Replace {remote_host} with {http.request.header.Cf-Connecting-Ip}
            # if Caddy sits behind Cloudflare.
            header_up x-flowsery-real-ip {remote_host}
 
            header_up X-Real-IP {remote_host}
            header_up X-Forwarded-For {remote_host}
            header_up X-Forwarded-Proto {scheme}
        }
    }
 
    # Your other site directives...
}

Note: If your server already uses an /api/track path, add data-api to the Flowsery Analytics script tag to direct events elsewhere. For example, data-api="/flowsery-events" sends data to /flowsery-events instead.

Important: If every visitor appears to be in the same location in your dashboard, confirm that x-flowsery-real-ip is set to the real visitor IP (not the proxy server IP) when forwarding requests to the Flowsery Analytics /events endpoint.

2. Optional: Enable Caching

For better performance, you can add a caching layer:

Text
your_domain.com {
    # Cache settings
    cache {
        path /var/cache/caddy
        ttl 1y
        capacity 10GB
    }
 
    handle /js/main.js {
        cache
        reverse_proxy https://analytics.flowsery.com {
            header_up Host {upstream_hostport}
            header_up X-Real-IP {remote_host}
            header_up X-Forwarded-For {remote_host}
            header_up X-Forwarded-Proto {scheme}
        }
 
        header Cache-Control "public, max-age=31536000"
        header Expires "1y"
    }
 
    # ... remainder of the configuration
}

3. Modify the Script Tag

Replace the original Flowsery Analytics snippet with the proxied version:

HTML
<script defer data-fl-website-id="flid_******" src="/js/main.js"></script>
Terminal
# Validate the configuration
caddy validate
 
# If validation passes, reload Caddy
caddy reload

Confirming It Works

To validate that the proxy is functioning correctly:

  1. Navigate to your website
  2. Open your browser's developer tools and switch to the Network tab
  3. Verify that analytics requests are served from your domain rather than analytics.flowsery.com

Caddy manages HTTPS certificates and HTTP/2 automatically, making it a solid choice for proxying analytics. Confirm that your Caddy server has sufficient disk space if you enable the cache configuration.

Troubleshooting

Every visitor appears from the same location

When all visitors show a single geographic location (typically your server's region), the proxy is not forwarding real visitor IPs correctly.

Resolution:

  1. Ensure your proxy sets x-flowsery-real-ip to the actual visitor IP (not the server IP) when forwarding requests to the Flowsery Analytics /events endpoint.
  2. If Caddy sits behind Cloudflare or another edge, {remote_host} is that upstream proxy — not the visitor. Use {http.request.header.Cf-Connecting-Ip} (Cloudflare) or {http.request.header.X-Real-Ip} (generic) instead.