@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 277 lines 5.14 KB
Raw
1 :8884
2
3 reverse_proxy 127.0.0.1:65535 {
4 @500 status 500
5 replace_status @500 400
6
7 @all status 2xx 3xx 4xx 5xx
8 replace_status @all {http.error.status_code}
9
10 replace_status {http.error.status_code}
11
12 @accel header X-Accel-Redirect *
13 handle_response @accel {
14 respond "Header X-Accel-Redirect!"
15 }
16
17 @another {
18 header X-Another *
19 }
20 handle_response @another {
21 respond "Header X-Another!"
22 }
23
24 @401 status 401
25 handle_response @401 {
26 respond "Status 401!"
27 }
28
29 handle_response {
30 respond "Any! This should be last in the JSON!"
31 }
32
33 @403 {
34 status 403
35 }
36 handle_response @403 {
37 respond "Status 403!"
38 }
39
40 @multi {
41 status 401 403
42 status 404
43 header Foo *
44 header Bar *
45 }
46 handle_response @multi {
47 respond "Headers Foo, Bar AND statuses 401, 403 and 404!"
48 }
49
50 @200 status 200
51 handle_response @200 {
52 copy_response_headers {
53 include Foo Bar
54 }
55 respond "Copied headers from the response"
56 }
57
58 @201 status 201
59 handle_response @201 {
60 header Foo "Copying the response"
61 copy_response 404
62 }
63 }
64 ----------
65 {
66 "apps": {
67 "http": {
68 "servers": {
69 "srv0": {
70 "listen": [
71 ":8884"
72 ],
73 "routes": [
74 {
75 "handle": [
76 {
77 "handle_response": [
78 {
79 "match": {
80 "status_code": [
81 500
82 ]
83 },
84 "status_code": 400
85 },
86 {
87 "match": {
88 "status_code": [
89 2,
90 3,
91 4,
92 5
93 ]
94 },
95 "status_code": "{http.error.status_code}"
96 },
97 {
98 "match": {
99 "headers": {
100 "X-Accel-Redirect": [
101 "*"
102 ]
103 }
104 },
105 "routes": [
106 {
107 "handle": [
108 {
109 "body": "Header X-Accel-Redirect!",
110 "handler": "static_response"
111 }
112 ]
113 }
114 ]
115 },
116 {
117 "match": {
118 "headers": {
119 "X-Another": [
120 "*"
121 ]
122 }
123 },
124 "routes": [
125 {
126 "handle": [
127 {
128 "body": "Header X-Another!",
129 "handler": "static_response"
130 }
131 ]
132 }
133 ]
134 },
135 {
136 "match": {
137 "status_code": [
138 401
139 ]
140 },
141 "routes": [
142 {
143 "handle": [
144 {
145 "body": "Status 401!",
146 "handler": "static_response"
147 }
148 ]
149 }
150 ]
151 },
152 {
153 "match": {
154 "status_code": [
155 403
156 ]
157 },
158 "routes": [
159 {
160 "handle": [
161 {
162 "body": "Status 403!",
163 "handler": "static_response"
164 }
165 ]
166 }
167 ]
168 },
169 {
170 "match": {
171 "headers": {
172 "Bar": [
173 "*"
174 ],
175 "Foo": [
176 "*"
177 ]
178 },
179 "status_code": [
180 401,
181 403,
182 404
183 ]
184 },
185 "routes": [
186 {
187 "handle": [
188 {
189 "body": "Headers Foo, Bar AND statuses 401, 403 and 404!",
190 "handler": "static_response"
191 }
192 ]
193 }
194 ]
195 },
196 {
197 "match": {
198 "status_code": [
199 200
200 ]
201 },
202 "routes": [
203 {
204 "handle": [
205 {
206 "handler": "copy_response_headers",
207 "include": [
208 "Foo",
209 "Bar"
210 ]
211 },
212 {
213 "body": "Copied headers from the response",
214 "handler": "static_response"
215 }
216 ]
217 }
218 ]
219 },
220 {
221 "match": {
222 "status_code": [
223 201
224 ]
225 },
226 "routes": [
227 {
228 "handle": [
229 {
230 "handler": "headers",
231 "response": {
232 "set": {
233 "Foo": [
234 "Copying the response"
235 ]
236 }
237 }
238 },
239 {
240 "handler": "copy_response",
241 "status_code": 404
242 }
243 ]
244 }
245 ]
246 },
247 {
248 "status_code": "{http.error.status_code}"
249 },
250 {
251 "routes": [
252 {
253 "handle": [
254 {
255 "body": "Any! This should be last in the JSON!",
256 "handler": "static_response"
257 }
258 ]
259 }
260 ]
261 }
262 ],
263 "handler": "reverse_proxy",
264 "upstreams": [
265 {
266 "dial": "127.0.0.1:65535"
267 }
268 ]
269 }
270 ]
271 }
272 ]
273 }
274 }
275 }
276 }
277 }