Repository navigation
Expand file tree
/
Copy pathCaddyfile
More file actions
94 lines (84 loc) · 1.81 KB
/
Copy pathCaddyfile
File metadata and controls
94 lines (84 loc) · 1.81 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
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
{
debug
http_port 80
https_port 443
order cache before rewrite
cache {
cache_name CaddyCache
}
log {
level INFO
output file /data/caddy/log/caddy.log {
roll_size 10MB
roll_keep 10
}
}
}
(log) {
log {
format transform `{request>headers>X-Forwarded-For>[0]:request>remote_ip} - {user_id} [{ts}] "{request>method} {request>uri} {request>proto}" {status} {size} "{request>headers>Referer>[0]}" "{request>headers>User-Agent>[0]}"` {
time_format "02/Jan/2006:15:04:05 -0700"
}
output file /data/caddy/log/{args[0]}/access.log {
roll_size 10MB
roll_keep 10
roll_keep_for 24h
}
}
}
(error_page) {
handle_errors {
rewrite * /{err.status_code}.html
root * /data/caddy/pages/errors
file_server
}
}
(encode) {
encode {
zstd best
br 5 v2
gzip 5
minimum_length 1024
}
}
(cache) {
cache {
allowed_http_verbs GET
stale {args[0]}
ttl {args[1]}
}
}
(header_realip) {
header_up X-Real-IP {remote_host}
header_up X-Real-IP {http.request.header.CF-Connecting-IP}
header_up X-Forwarded-For {http.request.header.CF-Connecting-IP}
header_up X-Forwarded-Proto {http.request.header.CF-Visitor}
}
(tls) {
tls {
dns {args[0]} {args[1]}
}
}
(rate_limit) {
route /* {
rate_limit {remote.ip} {args[0]}r/m 10000 429
}
}
(route_nocache) {
route {args[0]} {
rate_limit {remote.ip} {args[1]}r/m 10000 429
cache {
stale 0s
ttl 0s
}
}
}
:80 {
root * /data/caddy/pages/demo
file_server
import cache 0s 20s
import log 80
import error_page
import encode
}
import /data/caddy/config.d/*