@marcel91200 / caddy Mirror · read-only
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 11, 01:00 UTC

master
caddyfiletest 336 lines 6.03 KB
Raw
1 :80 {
2 @matcher {
3 method GET
4 }
5 respond @matcher "get"
6
7 @matcher2 method POST
8 respond @matcher2 "post"
9
10 @matcher3 not method PUT
11 respond @matcher3 "not put"
12
13 @matcher4 vars "{http.request.uri}" "/vars-matcher"
14 respond @matcher4 "from vars matcher"
15
16 @matcher5 vars_regexp static "{http.request.uri}" `\.([a-f0-9]{6})\.(css|js)$`
17 respond @matcher5 "from vars_regexp matcher with name"
18
19 @matcher6 vars_regexp "{http.request.uri}" `\.([a-f0-9]{6})\.(css|js)$`
20 respond @matcher6 "from vars_regexp matcher without name"
21
22 @matcher7 `path('/foo*') && method('GET')`
23 respond @matcher7 "inline expression matcher shortcut"
24
25 @matcher8 {
26 header Foo bar
27 header Foo foobar
28 header Bar foo
29 }
30 respond @matcher8 "header matcher merging values of the same field"
31
32 @matcher9 {
33 query foo=bar foo=baz bar=foo
34 query bar=baz
35 }
36 respond @matcher9 "query matcher merging pairs with the same keys"
37
38 @matcher10 {
39 header !Foo
40 header Bar foo
41 }
42 respond @matcher10 "header matcher with null field matcher"
43
44 @matcher11 remote_ip private_ranges
45 respond @matcher11 "remote_ip matcher with private ranges"
46
47 @matcher12 client_ip private_ranges
48 respond @matcher12 "client_ip matcher with private ranges"
49
50 @matcher13 {
51 remote_ip 1.1.1.1
52 remote_ip 2.2.2.2
53 }
54 respond @matcher13 "remote_ip merged"
55
56 @matcher14 {
57 client_ip 1.1.1.1
58 client_ip 2.2.2.2
59 }
60 respond @matcher14 "client_ip merged"
61 }
62 ----------
63 {
64 "apps": {
65 "http": {
66 "servers": {
67 "srv0": {
68 "listen": [
69 ":80"
70 ],
71 "routes": [
72 {
73 "match": [
74 {
75 "method": [
76 "GET"
77 ]
78 }
79 ],
80 "handle": [
81 {
82 "body": "get",
83 "handler": "static_response"
84 }
85 ]
86 },
87 {
88 "match": [
89 {
90 "method": [
91 "POST"
92 ]
93 }
94 ],
95 "handle": [
96 {
97 "body": "post",
98 "handler": "static_response"
99 }
100 ]
101 },
102 {
103 "match": [
104 {
105 "not": [
106 {
107 "method": [
108 "PUT"
109 ]
110 }
111 ]
112 }
113 ],
114 "handle": [
115 {
116 "body": "not put",
117 "handler": "static_response"
118 }
119 ]
120 },
121 {
122 "match": [
123 {
124 "vars": {
125 "{http.request.uri}": [
126 "/vars-matcher"
127 ]
128 }
129 }
130 ],
131 "handle": [
132 {
133 "body": "from vars matcher",
134 "handler": "static_response"
135 }
136 ]
137 },
138 {
139 "match": [
140 {
141 "vars_regexp": {
142 "{http.request.uri}": {
143 "name": "static",
144 "pattern": "\\.([a-f0-9]{6})\\.(css|js)$"
145 }
146 }
147 }
148 ],
149 "handle": [
150 {
151 "body": "from vars_regexp matcher with name",
152 "handler": "static_response"
153 }
154 ]
155 },
156 {
157 "match": [
158 {
159 "vars_regexp": {
160 "{http.request.uri}": {
161 "name": "matcher6",
162 "pattern": "\\.([a-f0-9]{6})\\.(css|js)$"
163 }
164 }
165 }
166 ],
167 "handle": [
168 {
169 "body": "from vars_regexp matcher without name",
170 "handler": "static_response"
171 }
172 ]
173 },
174 {
175 "match": [
176 {
177 "expression": {
178 "expr": "path('/foo*') \u0026\u0026 method('GET')",
179 "name": "matcher7"
180 }
181 }
182 ],
183 "handle": [
184 {
185 "body": "inline expression matcher shortcut",
186 "handler": "static_response"
187 }
188 ]
189 },
190 {
191 "match": [
192 {
193 "header": {
194 "Bar": [
195 "foo"
196 ],
197 "Foo": [
198 "bar",
199 "foobar"
200 ]
201 }
202 }
203 ],
204 "handle": [
205 {
206 "body": "header matcher merging values of the same field",
207 "handler": "static_response"
208 }
209 ]
210 },
211 {
212 "match": [
213 {
214 "query": {
215 "bar": [
216 "foo",
217 "baz"
218 ],
219 "foo": [
220 "bar",
221 "baz"
222 ]
223 }
224 }
225 ],
226 "handle": [
227 {
228 "body": "query matcher merging pairs with the same keys",
229 "handler": "static_response"
230 }
231 ]
232 },
233 {
234 "match": [
235 {
236 "header": {
237 "Bar": [
238 "foo"
239 ],
240 "Foo": null
241 }
242 }
243 ],
244 "handle": [
245 {
246 "body": "header matcher with null field matcher",
247 "handler": "static_response"
248 }
249 ]
250 },
251 {
252 "match": [
253 {
254 "remote_ip": {
255 "ranges": [
256 "192.168.0.0/16",
257 "172.16.0.0/12",
258 "10.0.0.0/8",
259 "127.0.0.1/8",
260 "fd00::/8",
261 "::1"
262 ]
263 }
264 }
265 ],
266 "handle": [
267 {
268 "body": "remote_ip matcher with private ranges",
269 "handler": "static_response"
270 }
271 ]
272 },
273 {
274 "match": [
275 {
276 "client_ip": {
277 "ranges": [
278 "192.168.0.0/16",
279 "172.16.0.0/12",
280 "10.0.0.0/8",
281 "127.0.0.1/8",
282 "fd00::/8",
283 "::1"
284 ]
285 }
286 }
287 ],
288 "handle": [
289 {
290 "body": "client_ip matcher with private ranges",
291 "handler": "static_response"
292 }
293 ]
294 },
295 {
296 "match": [
297 {
298 "remote_ip": {
299 "ranges": [
300 "1.1.1.1",
301 "2.2.2.2"
302 ]
303 }
304 }
305 ],
306 "handle": [
307 {
308 "body": "remote_ip merged",
309 "handler": "static_response"
310 }
311 ]
312 },
313 {
314 "match": [
315 {
316 "client_ip": {
317 "ranges": [
318 "1.1.1.1",
319 "2.2.2.2"
320 ]
321 }
322 }
323 ],
324 "handle": [
325 {
326 "body": "client_ip merged",
327 "handler": "static_response"
328 }
329 ]
330 }
331 ]
332 }
333 }
334 }
335 }
336 }