forked from caddyserver/cache-handler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Caddyfile
374 lines (334 loc) · 7.82 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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
{
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 {
cache {
ttl 5s
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 /etcd-configuration {
cache {
ttl 5s
etcd {
configuration {
Endpoints etcd:2379 etcd:2379
AutoSyncInterval 1s
DialTimeout 1s
DialKeepAliveTime 1s
DialKeepAliveTimeout 1s
MaxCallSendMsgSize 10000000
MaxCallRecvMsgSize 10000000
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 {
cache {
ttl 5s
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-configuration {
cache {
ttl 5s
redis {
configuration {
Addr 127.0.0.1:6379
DB 0
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 5s
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 /must-revalidate {
cache {
ttl 5s
stale 5s
}
header Cache-Control "must-revalidate"
reverse_proxy 127.0.0.1:81
}
route /cache-authorization {
cache {
cache_keys {
/.+ {
headers Authorization
}
}
}
header Souin-Cache-Control public
respond "Hello to the authenticated user."
}
route /bypass {
cache {
mode bypass
}
header Cache-Control "no-store"
respond "Hello bypass"
}
route /bypass_request {
cache {
mode bypass_request
}
respond "Hello bypass_request"
}
route /bypass_response {
cache {
mode bypass_response
}
header Cache-Control "no-cache, no-store"
respond "Hello bypass_response"
}
route /strict_request {
cache {
mode strict
}
respond "Hello strict"
}
route /strict_response {
cache {
mode strict
}
header Cache-Control "no-cache, no-store"
respond "Hello strict"
}
cache @souin-api {
}
# ESI part
route /esi-include {
cache
header Content-Type text/html
respond "<h1>ESI INCLUDE</h1>"
}
route /alt-esi-include {
cache
header Content-Type text/html
respond "<h1>ALTERNATE ESI INCLUDE</h1>"
}
route /esi {
cache
header Content-Type text/html
respond `<esi:include src="http://localhost:4443/esi-include" alt=http://localhost:4443/alt-esi-include />`
}