Repository navigation
Expand file tree
/
Copy pathCaddyfile.example
More file actions
66 lines (59 loc) · 1.6 KB
/
Copy pathCaddyfile.example
File metadata and controls
66 lines (59 loc) · 1.6 KB
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
# Caddyfile for hyperhack. Copy it, replace example.com and /srv/hyperhack.
#
# Needs Caddy built with two plugins (README → Caddy):
# xcaddy build v2.11.7 \
# --with github.com/mholt/caddy-ratelimit@v0.1.0 \
# --with github.com/hslatman/caddy-crowdsec-bouncer/http@v0.14.1
#
# CROWDSEC_API_URL and CROWDSEC_API_KEY come from Caddy's environment.
# The CrowdSec LAPI also defaults to port 8080: move one of them if both run on the host.
{
order crowdsec first
order rate_limit after crowdsec
crowdsec {
api_url {$CROWDSEC_API_URL}
api_key {$CROWDSEC_API_KEY}
}
}
example.com {
crowdsec
# Per client IP. Static files and assets are not counted.
@limited not path /static/* /assets/*
rate_limit @limited {
zone per_client {
key {remote_host}
events 1200
window 1m
}
}
header {
Strict-Transport-Security "max-age=31536000"
-Server
}
encode zstd gzip
# Private endpoints. VictoriaMetrics and /reindex callers reach the service directly.
# A handle block, because handle runs before a bare respond.
@private path /metrics /metrics/* /reindex /reindex/*
handle @private {
respond 404
}
# Assets straight from the mirror (vault/assets/), allowed extensions only.
handle /assets/* {
@allowed path *.png *.jpg *.jpeg *.webp *.avif *.gif *.svg *.mp4 *.webm
handle @allowed {
root * /srv/hyperhack/vault
header {
X-Content-Type-Options nosniff
Content-Security-Policy "default-src 'none'; img-src 'self'; style-src 'unsafe-inline'; sandbox"
}
file_server
}
respond 404
}
handle {
request_body /api/* {
max_size 16KB
}
reverse_proxy 127.0.0.1:8080
}
}