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
| 1 | foo.localhost { |
| 2 | root * /srv |
| 3 | error /private* "Unauthorized" 410 |
| 4 | error /fivehundred* "Internal Server Error" 500 |
| 5 | |
| 6 | handle_errors 5xx { |
| 7 | respond "Error In range [500 .. 599]" |
| 8 | } |
| 9 | handle_errors 410 { |
| 10 | respond "404 or 410 error" |
| 11 | } |
| 12 | } |
| 13 | |
| 14 | bar.localhost { |
| 15 | root * /srv |
| 16 | error /private* "Unauthorized" 410 |
| 17 | error /fivehundred* "Internal Server Error" 500 |
| 18 | |
| 19 | handle_errors 5xx { |
| 20 | respond "Error In range [500 .. 599] from second site" |
| 21 | } |
| 22 | handle_errors 410 { |
| 23 | respond "404 or 410 error from second site" |
| 24 | } |
| 25 | } |
| 26 | ---------- |
| 27 | { |
| 28 | "apps": { |
| 29 | "http": { |
| 30 | "servers": { |
| 31 | "srv0": { |
| 32 | "listen": [ |
| 33 | ":443" |
| 34 | ], |
| 35 | "routes": [ |
| 36 | { |
| 37 | "match": [ |
| 38 | { |
| 39 | "host": [ |
| 40 | "foo.localhost" |
| 41 | ] |
| 42 | } |
| 43 | ], |
| 44 | "handle": [ |
| 45 | { |
| 46 | "handler": "subroute", |
| 47 | "routes": [ |
| 48 | { |
| 49 | "handle": [ |
| 50 | { |
| 51 | "handler": "vars", |
| 52 | "root": "/srv" |
| 53 | } |
| 54 | ] |
| 55 | }, |
| 56 | { |
| 57 | "handle": [ |
| 58 | { |
| 59 | "error": "Internal Server Error", |
| 60 | "handler": "error", |
| 61 | "status_code": 500 |
| 62 | } |
| 63 | ], |
| 64 | "match": [ |
| 65 | { |
| 66 | "path": [ |
| 67 | "/fivehundred*" |
| 68 | ] |
| 69 | } |
| 70 | ] |
| 71 | }, |
| 72 | { |
| 73 | "handle": [ |
| 74 | { |
| 75 | "error": "Unauthorized", |
| 76 | "handler": "error", |
| 77 | "status_code": 410 |
| 78 | } |
| 79 | ], |
| 80 | "match": [ |
| 81 | { |
| 82 | "path": [ |
| 83 | "/private*" |
| 84 | ] |
| 85 | } |
| 86 | ] |
| 87 | } |
| 88 | ] |
| 89 | } |
| 90 | ], |
| 91 | "terminal": true |
| 92 | }, |
| 93 | { |
| 94 | "match": [ |
| 95 | { |
| 96 | "host": [ |
| 97 | "bar.localhost" |
| 98 | ] |
| 99 | } |
| 100 | ], |
| 101 | "handle": [ |
| 102 | { |
| 103 | "handler": "subroute", |
| 104 | "routes": [ |
| 105 | { |
| 106 | "handle": [ |
| 107 | { |
| 108 | "handler": "vars", |
| 109 | "root": "/srv" |
| 110 | } |
| 111 | ] |
| 112 | }, |
| 113 | { |
| 114 | "handle": [ |
| 115 | { |
| 116 | "error": "Internal Server Error", |
| 117 | "handler": "error", |
| 118 | "status_code": 500 |
| 119 | } |
| 120 | ], |
| 121 | "match": [ |
| 122 | { |
| 123 | "path": [ |
| 124 | "/fivehundred*" |
| 125 | ] |
| 126 | } |
| 127 | ] |
| 128 | }, |
| 129 | { |
| 130 | "handle": [ |
| 131 | { |
| 132 | "error": "Unauthorized", |
| 133 | "handler": "error", |
| 134 | "status_code": 410 |
| 135 | } |
| 136 | ], |
| 137 | "match": [ |
| 138 | { |
| 139 | "path": [ |
| 140 | "/private*" |
| 141 | ] |
| 142 | } |
| 143 | ] |
| 144 | } |
| 145 | ] |
| 146 | } |
| 147 | ], |
| 148 | "terminal": true |
| 149 | } |
| 150 | ], |
| 151 | "errors": { |
| 152 | "routes": [ |
| 153 | { |
| 154 | "match": [ |
| 155 | { |
| 156 | "host": [ |
| 157 | "foo.localhost" |
| 158 | ] |
| 159 | } |
| 160 | ], |
| 161 | "handle": [ |
| 162 | { |
| 163 | "handler": "subroute", |
| 164 | "routes": [ |
| 165 | { |
| 166 | "handle": [ |
| 167 | { |
| 168 | "handler": "subroute", |
| 169 | "routes": [ |
| 170 | { |
| 171 | "handle": [ |
| 172 | { |
| 173 | "body": "Error In range [500 .. 599]", |
| 174 | "handler": "static_response" |
| 175 | } |
| 176 | ] |
| 177 | } |
| 178 | ] |
| 179 | } |
| 180 | ], |
| 181 | "match": [ |
| 182 | { |
| 183 | "expression": "{http.error.status_code} \u003e= 500 \u0026\u0026 {http.error.status_code} \u003c= 599" |
| 184 | } |
| 185 | ] |
| 186 | }, |
| 187 | { |
| 188 | "handle": [ |
| 189 | { |
| 190 | "handler": "subroute", |
| 191 | "routes": [ |
| 192 | { |
| 193 | "handle": [ |
| 194 | { |
| 195 | "body": "404 or 410 error", |
| 196 | "handler": "static_response" |
| 197 | } |
| 198 | ] |
| 199 | } |
| 200 | ] |
| 201 | } |
| 202 | ], |
| 203 | "match": [ |
| 204 | { |
| 205 | "expression": "{http.error.status_code} in [410]" |
| 206 | } |
| 207 | ] |
| 208 | } |
| 209 | ] |
| 210 | } |
| 211 | ], |
| 212 | "terminal": true |
| 213 | }, |
| 214 | { |
| 215 | "match": [ |
| 216 | { |
| 217 | "host": [ |
| 218 | "bar.localhost" |
| 219 | ] |
| 220 | } |
| 221 | ], |
| 222 | "handle": [ |
| 223 | { |
| 224 | "handler": "subroute", |
| 225 | "routes": [ |
| 226 | { |
| 227 | "handle": [ |
| 228 | { |
| 229 | "handler": "subroute", |
| 230 | "routes": [ |
| 231 | { |
| 232 | "handle": [ |
| 233 | { |
| 234 | "body": "Error In range [500 .. 599] from second site", |
| 235 | "handler": "static_response" |
| 236 | } |
| 237 | ] |
| 238 | } |
| 239 | ] |
| 240 | } |
| 241 | ], |
| 242 | "match": [ |
| 243 | { |
| 244 | "expression": "{http.error.status_code} \u003e= 500 \u0026\u0026 {http.error.status_code} \u003c= 599" |
| 245 | } |
| 246 | ] |
| 247 | }, |
| 248 | { |
| 249 | "handle": [ |
| 250 | { |
| 251 | "handler": "subroute", |
| 252 | "routes": [ |
| 253 | { |
| 254 | "handle": [ |
| 255 | { |
| 256 | "body": "404 or 410 error from second site", |
| 257 | "handler": "static_response" |
| 258 | } |
| 259 | ] |
| 260 | } |
| 261 | ] |
| 262 | } |
| 263 | ], |
| 264 | "match": [ |
| 265 | { |
| 266 | "expression": "{http.error.status_code} in [410]" |
| 267 | } |
| 268 | ] |
| 269 | } |
| 270 | ] |
| 271 | } |
| 272 | ], |
| 273 | "terminal": true |
| 274 | } |
| 275 | ] |
| 276 | } |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | } |