Skip to main content
To proxy CrispStats with nginx, add one location block for /k3x9qe/ inside your site’s server block that passes requests to https://in.crispstats.com/p/, then point the script tag at the path with data-api. Ad blockers that stop known analytics hosts then see a request to your own domain, so those visitors are counted. The block turns off nginx’s default of passing every request header and sets only the ones analytics needs, so your visitors’ cookies never leave your server. Use your own path instead of /k3x9qe: Settings, Tracking code, Proxy through your own domain proposes one for your site. See the proxy overview for how the path, the check and signing work on every host.

Set up the proxy

1

Add the location block

Add it inside the server block of your site, then reload nginx.
nginx.conf
2

Behind a load balancer, set the real address first

If nginx sits behind a load balancer or CDN, configure real_ip_header and set_real_ip_from first, so $remote_addr is the visitor and not the load balancer. Otherwise every visit looks like it comes from one address, and visitors merge.
3

Point the script tag at the path

src loads the script from your domain, and data-api sends events and visitor id requests to the same path:
data-api is required. Without it the script sends events to /e on your own domain, and those requests fail.
4

Run the setup check

Open the check through your proxy, in a browser, on your own site:
Look for "visitorAddressForwarded": true and "cookiesForwarded": false. The proxy overview explains every field.

Visitor address and location

nginx passes the visitor’s address in X-Forwarded-For from $remote_addr. The collector uses it for the daily visitor hash and your excluded IP addresses, then discards it. nginx does not know where the visitor is, so the collector looks the country, region and city up from that address itself. If your setup knows the location (for example from a CDN header), you can set x-crispstats-country, x-crispstats-region and x-crispstats-city yourself, and those win. See location.

Sign the requests (optional)

Signing proves a forwarded request came from your proxy. Reveal the secret (cs_px_…) in Settings, Tracking code, Proxy through your own domain, Advanced: sign proxied requests, and add this line to the location block with the secret in place of the placeholder:
nginx
Reload nginx, then look for "signed": true in the setup check. Keep the config file readable only by the accounts that need it. See sign proxied requests.

FAQ

By default nginx passes every request header upstream, including cookies and authorization. Turning it off and setting only the listed headers by hand keeps them out.
^~ makes this prefix match win over regular-expression locations, so a rule for .js files elsewhere in your config does not catch /k3x9qe/d.js.
The collector sees your load balancer’s address. Set real_ip_header and set_real_ip_from, reload, and check for "visitorAddressForwarded": true.

Next steps

Proxy overview

The path, the check, caching, limits and signing.

Proxy with Caddy

The same rule for Caddy.

Exclude IP addresses

Compared with the forwarded visitor address.
Last modified on November 26, 2026