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 | { |
| 2 | http_port 3010 |
| 3 | } |
| 4 | localhost:3010 { |
| 5 | root * /srv |
| 6 | error /private* "Unauthorized" 410 |
| 7 | error /hidden* "Not found" 404 |
| 8 | |
| 9 | handle_errors 4xx { |
| 10 | respond "Error in the [400 .. 499] range" |
| 11 | } |
| 12 | } |
| 13 | ---------- |
| 14 | { |
| 15 | "apps": { |
| 16 | "http": { |
| 17 | "http_port": 3010, |
| 18 | "servers": { |
| 19 | "srv0": { |
| 20 | "listen": [ |
| 21 | ":3010" |
| 22 | ], |
| 23 | "routes": [ |
| 24 | { |
| 25 | "match": [ |
| 26 | { |
| 27 | "host": [ |
| 28 | "localhost" |
| 29 | ] |
| 30 | } |
| 31 | ], |
| 32 | "handle": [ |
| 33 | { |
| 34 | "handler": "subroute", |
| 35 | "routes": [ |
| 36 | { |
| 37 | "handle": [ |
| 38 | { |
| 39 | "handler": "vars", |
| 40 | "root": "/srv" |
| 41 | } |
| 42 | ] |
| 43 | }, |
| 44 | { |
| 45 | "handle": [ |
| 46 | { |
| 47 | "error": "Unauthorized", |
| 48 | "handler": "error", |
| 49 | "status_code": 410 |
| 50 | } |
| 51 | ], |
| 52 | "match": [ |
| 53 | { |
| 54 | "path": [ |
| 55 | "/private*" |
| 56 | ] |
| 57 | } |
| 58 | ] |
| 59 | }, |
| 60 | { |
| 61 | "handle": [ |
| 62 | { |
| 63 | "error": "Not found", |
| 64 | "handler": "error", |
| 65 | "status_code": 404 |
| 66 | } |
| 67 | ], |
| 68 | "match": [ |
| 69 | { |
| 70 | "path": [ |
| 71 | "/hidden*" |
| 72 | ] |
| 73 | } |
| 74 | ] |
| 75 | } |
| 76 | ] |
| 77 | } |
| 78 | ], |
| 79 | "terminal": true |
| 80 | } |
| 81 | ], |
| 82 | "errors": { |
| 83 | "routes": [ |
| 84 | { |
| 85 | "match": [ |
| 86 | { |
| 87 | "host": [ |
| 88 | "localhost" |
| 89 | ] |
| 90 | } |
| 91 | ], |
| 92 | "handle": [ |
| 93 | { |
| 94 | "handler": "subroute", |
| 95 | "routes": [ |
| 96 | { |
| 97 | "handle": [ |
| 98 | { |
| 99 | "handler": "subroute", |
| 100 | "routes": [ |
| 101 | { |
| 102 | "handle": [ |
| 103 | { |
| 104 | "body": "Error in the [400 .. 499] range", |
| 105 | "handler": "static_response" |
| 106 | } |
| 107 | ] |
| 108 | } |
| 109 | ] |
| 110 | } |
| 111 | ], |
| 112 | "match": [ |
| 113 | { |
| 114 | "expression": "{http.error.status_code} \u003e= 400 \u0026\u0026 {http.error.status_code} \u003c= 499" |
| 115 | } |
| 116 | ] |
| 117 | } |
| 118 | ] |
| 119 | } |
| 120 | ], |
| 121 | "terminal": true |
| 122 | } |
| 123 | ] |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | } |