1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
grafana.stream.waow.tech {
reverse_proxy grafana:3000
}
stream.89-167-122-160.sslip.io, stream.waow.tech, jetstream.waow.tech {
# edge admission control (mholt/caddy-ratelimit, sliding window).
# per-IP keys grouped by /24 (v4) and /56 (v6) so address cycling
# inside one allocation shares a bucket. limits bound REQUEST rates
# only; concurrent-subscriber and cold-replay caps live in-process
# (the proxy cannot see what a connection costs the archive).
rate_limit {
# websocket connect attempts: a healthy consumer reconnects rarely;
# 30 per 5m per /24 tolerates flapping without permitting a spray
zone ws_connect {
match {
header Connection *Upgrade*
}
key {remote_host}
events 30
window 5m
ipv4_prefix 24
ipv6_prefix 56
}
# keyed archive traffic: a 32 MB/s consumer runs ~150 getBlock/s
# (~214 KB avg block), so the ceiling must sit well above that;
# byte-rate fairness is the key ring's job, this only stops
# request-rate floods with a forged bearer header
zone xrpc_keyed {
match {
path /xrpc/*
header Authorization Bearer*
}
key {remote_host}
events 15000
window 1m
}
# everything anonymous: static site, /metrics, /status, and
# unauthenticated xrpc probes (401 spray) share one modest bucket
zone anon_http {
match {
not header Connection *Upgrade*
not header Authorization Bearer*
}
key {remote_host}
events 240
window 1m
ipv4_prefix 24
ipv6_prefix 56
}
}
# Public playground; static assets and a deploy-time summary snapshot.
root * /srv/site
redir /strata /strata/ permanent
redir /_strata-preview /strata/ permanent
handle_path /_strata-preview/* {
redir * /strata{uri} permanent
}
handle /strata/* {
# Preserve summary API URLs for clients of the former UI.
@strata_api path /strata/api /strata/api/*
handle @strata_api {
uri strip_prefix /strata
reverse_proxy https://strata.zat.dev {
header_up Host strata.zat.dev
}
}
handle /strata/assets/* {
header Cache-Control "public, max-age=31536000, immutable"
file_server {
precompressed gzip
}
}
handle {
header Cache-Control "public, max-age=60, stale-while-revalidate=86400, stale-if-error=604800"
file_server {
precompressed gzip
}
}
}
@home path / /index.html
handle @home {
header Cache-Control "no-cache"
encode zstd gzip
templates {
mime text/html
}
file_server
}
# the pages name these with a ?v= key that changes with their content, so a
# browser may reuse its copy for a day without asking; a forgotten key bump
# is stale for at most that long
@keyed path /ambient.js /brand.css /river.js
handle @keyed {
header Cache-Control "public, max-age=86400, stale-while-revalidate=604800"
encode zstd gzip
file_server
}
@static path /llms.txt /favicon.svg
handle @static {
encode zstd gzip
file_server
}
handle /stats {
header Cache-Control "no-cache"
encode zstd gzip
rewrite * /stats.html
file_server
}
@statushtml {
path /status
header Accept *text/html*
}
handle @statushtml {
encode zstd gzip
rewrite * /statuspage.html
file_server
}
handle /metrics {
reverse_proxy stream:6060
}
handle {
# subscriber websockets survive config reloads: without this, any
# caddy reload severs every proxied stream and consumers fail over
reverse_proxy stream:8080 {
stream_close_delay 24h
}
}
}