forked from darkweak/souin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Caddyfile
257 lines (233 loc) · 5.62 KB
/
Caddyfile
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
{
order cache before rewrite
debug
log {
level debug
}
cache {
allowed_http_verbs GET POST
api {
prometheus
souin
}
cdn {
dynamic
strategy hard
}
regex {
exclude /test2.*
}
ttl 1000s
timeout {
backend 10s
cache 100ms
}
default_cache_control public
}
}
:4443
respond "Hello World!"
@match path /test1*
@match2 path /test2*
@matchdefault path /default
@souin-api path /souin-api*
cache @match {
ttl 5s
}
cache @match2 {
ttl 50s
}
cache @matchdefault {
ttl 5s
}
route /badger-configuration {
cache {
ttl 15s
badger {
configuration {
Dir /tmp/badger-configuration
ValueDir match2
ValueLogFileSize 16777216
MemTableSize 4194304
ValueThreshold 524288
}
}
}
respond "Hello badger"
}
# route /etcd-configuration {
# cache {
# ttl 15s
# etcd {
# configuration {
# Endpoints etcd1:2379 etcd2:2379 etcd3:2379
# AutoSyncInterval 1s
# DialTimeout 1s
# DialKeepAliveTime 1s
# DialKeepAliveTimeout 1s
# MaxCallSendMsgSize 10000000
# MaxCallRecvMsgSize 10000000
# Username john
# Password doe
# RejectOldCluster false
# PermitWithoutStream false
# }
# }
# }
# respond "Hello etcd"
# }
route /nuts-configuration {
cache {
ttl 15s
nuts {
configuration {
Dir /tmp/nuts-configuration
EntryIdxMode 1
RWMode 0
SegmentSize 1024
NodeNum 42
SyncEnable true
StartFileLoadingMode 1
}
}
}
respond "Hello nuts"
}
route /redis-configuration {
cache {
ttl 15s
redis {
configuration {
Network my-network
Addr 127.0.0.1:6379
Username user
Password password
DB 1
MaxRetries 1
MinRetryBackoff 5s
MaxRetryBackoff 5s
DialTimeout 5s
ReadTimeout 5s
WriteTimeout 5s
PoolFIFO true
PoolSize 99999
PoolTimeout 10s
MinIdleConns 100
MaxIdleConns 100
ConnMaxIdleTime 5s
ConnMaxLifetime 5s
}
}
}
respond "Hello redis"
}
route /redis-url {
cache {
ttl 15s
redis {
url 127.0.0.1:6379
}
}
respond "Hello redis url"
}
route /vary {
cache {
ttl 15s
}
header Vary X-Something
respond "Hello {http.request.header.X-Something}"
}
route /cache-s-maxage {
cache
header Cache-Control "s-maxage=10"
respond "Hello, s-maxage!"
}
route /cache-maxage {
cache
header Cache-Control "max-age=5"
respond "Hello, max-age!"
}
route /cache-maxstale {
cache {
ttl 3s
stale 5s
}
header Cache-Control "max-age=5"
respond "Hello, max-age!"
}
route /not-modified {
cache {
ttl 5s
}
reverse_proxy 127.0.0.1:9000
}
route /no-reverse-proxy {
cache
reverse_proxy 127.0.0.1:9000
}
route /surrogate-keys {
cache
header Surrogate-Key "KEY-{http.request.header.X-Surrogate-Key-Suffix}"
header Vary X-Surrogate-Key-Suffix,Accept-Encoding
respond "Hello {http.request.header.X-Surrogate-Key-Suffix}"
}
route /another-cache-status-name {
cache {
cache_name Another
}
}
route /backend-timeout {
cache {
timeout {
backend 1s
cache 1ms
}
}
reverse_proxy 127.0.0.1:8081
}
route /stream {
cache
reverse_proxy 127.0.0.1:81
}
route /gzip {
cache
encode {
gzip
minimum_length 5
}
header Content-Type text/plain
respond "Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip. Hello, gzip."
}
route /custom-key/without-* {
cache {
cache_keys {
body {
disable_body
}
host {
disable_host
}
method {
disable_method
}
everything-with-content-type {
disable_method
headers Content-Type
}
}
}
respond "Hello to the authenticated user."
}
route /cache-authorization {
cache {
cache_keys {
/.+ {
headers Authorization
}
}
}
header Souin-Cache-Control public
respond "Hello to the authenticated user."
}
cache @souin-api {
}