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 | :8881 { |
| 2 | php_fastcgi app:9000 { |
| 3 | env FOO bar |
| 4 | |
| 5 | @error status 4xx |
| 6 | handle_response @error { |
| 7 | root * /errors |
| 8 | rewrite * /{http.reverse_proxy.status_code}.html |
| 9 | file_server |
| 10 | } |
| 11 | } |
| 12 | } |
| 13 | ---------- |
| 14 | { |
| 15 | "apps": { |
| 16 | "http": { |
| 17 | "servers": { |
| 18 | "srv0": { |
| 19 | "listen": [ |
| 20 | ":8881" |
| 21 | ], |
| 22 | "routes": [ |
| 23 | { |
| 24 | "match": [ |
| 25 | { |
| 26 | "file": { |
| 27 | "try_files": [ |
| 28 | "{http.request.uri.path}/index.php" |
| 29 | ] |
| 30 | }, |
| 31 | "not": [ |
| 32 | { |
| 33 | "path": [ |
| 34 | "*/" |
| 35 | ] |
| 36 | } |
| 37 | ] |
| 38 | } |
| 39 | ], |
| 40 | "handle": [ |
| 41 | { |
| 42 | "handler": "static_response", |
| 43 | "headers": { |
| 44 | "Location": [ |
| 45 | "./{http.request.orig_uri.path.file_escaped}/{http.request.orig_uri.prefixed_query}" |
| 46 | ] |
| 47 | }, |
| 48 | "status_code": 308 |
| 49 | } |
| 50 | ] |
| 51 | }, |
| 52 | { |
| 53 | "match": [ |
| 54 | { |
| 55 | "file": { |
| 56 | "try_files": [ |
| 57 | "{http.request.uri.path}", |
| 58 | "{http.request.uri.path}/index.php", |
| 59 | "index.php" |
| 60 | ], |
| 61 | "split_path": [ |
| 62 | ".php" |
| 63 | ] |
| 64 | } |
| 65 | } |
| 66 | ], |
| 67 | "handle": [ |
| 68 | { |
| 69 | "handler": "rewrite", |
| 70 | "uri": "{http.matchers.file.relative}" |
| 71 | } |
| 72 | ] |
| 73 | }, |
| 74 | { |
| 75 | "match": [ |
| 76 | { |
| 77 | "path": [ |
| 78 | "*.php" |
| 79 | ] |
| 80 | } |
| 81 | ], |
| 82 | "handle": [ |
| 83 | { |
| 84 | "handle_response": [ |
| 85 | { |
| 86 | "match": { |
| 87 | "status_code": [ |
| 88 | 4 |
| 89 | ] |
| 90 | }, |
| 91 | "routes": [ |
| 92 | { |
| 93 | "handle": [ |
| 94 | { |
| 95 | "handler": "vars", |
| 96 | "root": "/errors" |
| 97 | } |
| 98 | ] |
| 99 | }, |
| 100 | { |
| 101 | "group": "group0", |
| 102 | "handle": [ |
| 103 | { |
| 104 | "handler": "rewrite", |
| 105 | "uri": "/{http.reverse_proxy.status_code}.html" |
| 106 | } |
| 107 | ] |
| 108 | }, |
| 109 | { |
| 110 | "handle": [ |
| 111 | { |
| 112 | "handler": "file_server", |
| 113 | "hide": [ |
| 114 | "./Caddyfile" |
| 115 | ] |
| 116 | } |
| 117 | ] |
| 118 | } |
| 119 | ] |
| 120 | } |
| 121 | ], |
| 122 | "handler": "reverse_proxy", |
| 123 | "transport": { |
| 124 | "env": { |
| 125 | "FOO": "bar" |
| 126 | }, |
| 127 | "protocol": "fastcgi", |
| 128 | "split_path": [ |
| 129 | ".php" |
| 130 | ] |
| 131 | }, |
| 132 | "upstreams": [ |
| 133 | { |
| 134 | "dial": "app:9000" |
| 135 | } |
| 136 | ] |
| 137 | } |
| 138 | ] |
| 139 | } |
| 140 | ] |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | } |