repos
/ analytics-django master

analytics-django

mirror archived upstream

Self-hostable website analytics on Django: a straightforward collector API, dashboards, a world map, and PDF reports.

analyticsdjangodockerhandcodedpythonself-hostedsqliteviteweb-analytics

1.2 KB · 62 lines · Caddyfile Raw History
 1# Caddyfile for analytics
 2#
 3# I like to use Caddy Server for simple reverse proxies since it has built in
 4# automatic HTTPS support. It is probably worth serving static files with
 5# Caddy too but I've honestly been too lazy to implement that. I just use
 6# whitenoise on Django for that.
 7{
 8  servers {
 9    protocol {
10      experimental_http3
11    }
12  }
13}
14
15(common) {
16  header /static/* {
17    Cache-Control "public, max-age=315360000"
18  }
19
20  header /media/* {
21    Cache-Control "public, max-age=315360000"
22  }
23
24  header /* {
25    Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
26    X-XSS-Protection "1; mode=block"
27    X-Frame-Options DENY
28    X-Content-Type-Options nosniff
29    -Server
30    -X-Powered-By
31  }
32
33  encode zstd gzip
34}
35
36analytics.example.com {
37  handle /collect/ {
38    @options {
39      method OPTIONS
40    }
41
42    respond @options 204
43
44    header Access-Control-Allow-Origin *
45    header Access-Control-Allow-Methods *
46    header Access-Control-Allow-Headers *
47    header Access-Control-Max-Age 31536000
48  }
49
50  handle /media/* {
51    uri strip_prefix /media
52    file_server {
53      root /srv/data/analytics/media
54    }
55  }
56
57  reverse_proxy localhost:8000
58
59  import common
60}