# Caddy

Two handlers in your Caddyfile serve the script from your domain and pass its counts on, with the visitor’s address.

Add two handlers to your site’s block in the Caddyfile:

```
handle /js/tally.js {
    reverse_proxy https://fiveb.ar {
        header_up Host {upstream_hostport}
        header_up -Cookie
        header_up -Authorization
    }
}

handle /api/tally {
    reverse_proxy https://fiveb.ar {
        header_up Host {upstream_hostport}
        header_up X-Fivebar-IP {client_ip}
        header_up -Cookie
        header_up -Authorization
    }
}
```

Behind a load balancer or a CDN, list it in Caddy’s `trusted_proxies`, so that `{client_ip}` is the visitor’s. See [Caddy’s help on reverse_proxy](https://caddyserver.com/docs/caddyfile/directives/reverse_proxy).

## Load the script

Once the proxy is live, load the script from your own domain. It sends its counts to the host it was loaded from, so nothing else changes:

```
<script async data-domain="example.com" src="/js/tally.js"></script>
```

Then [check it works](https://fiveb.ar/docs/proxy.md#check-it-works). If either path is already taken on your site, see [Other paths](https://fiveb.ar/docs/proxy.md#other-paths). [Proxying](https://fiveb.ar/docs/proxy.md) says how it works and which headers name the visitor.

---

fivebar is web analytics without cookies, at https://fiveb.ar. Every page of its docs is listed at https://fiveb.ar/docs/index.md.
