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 | :8886 |
| 2 | |
| 3 | route { |
| 4 | # Add trailing slash for directory requests |
| 5 | @canonicalPath { |
| 6 | file { |
| 7 | try_files {path}/index.php |
| 8 | } |
| 9 | not path */ |
| 10 | } |
| 11 | redir @canonicalPath ./{http.request.orig_uri.path.file_escaped}/{orig_?query} 308 |
| 12 | |
| 13 | # If the requested file does not exist, try index files |
| 14 | @indexFiles { |
| 15 | file { |
| 16 | try_files {path} {path}/index.php index.php |
| 17 | split_path .php |
| 18 | } |
| 19 | } |
| 20 | rewrite @indexFiles {file_match.relative} |
| 21 | |
| 22 | # Proxy PHP files to the FastCGI responder |
| 23 | @phpFiles { |
| 24 | path *.php |
| 25 | } |
| 26 | reverse_proxy @phpFiles 127.0.0.1:9000 { |
| 27 | transport fastcgi { |
| 28 | split .php |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | ---------- |
| 33 | { |
| 34 | "apps": { |
| 35 | "http": { |
| 36 | "servers": { |
| 37 | "srv0": { |
| 38 | "listen": [ |
| 39 | ":8886" |
| 40 | ], |
| 41 | "routes": [ |
| 42 | { |
| 43 | "handle": [ |
| 44 | { |
| 45 | "handler": "subroute", |
| 46 | "routes": [ |
| 47 | { |
| 48 | "handle": [ |
| 49 | { |
| 50 | "handler": "static_response", |
| 51 | "headers": { |
| 52 | "Location": [ |
| 53 | "./{http.request.orig_uri.path.file_escaped}/{http.request.orig_uri.prefixed_query}" |
| 54 | ] |
| 55 | }, |
| 56 | "status_code": 308 |
| 57 | } |
| 58 | ], |
| 59 | "match": [ |
| 60 | { |
| 61 | "file": { |
| 62 | "try_files": [ |
| 63 | "{http.request.uri.path}/index.php" |
| 64 | ] |
| 65 | }, |
| 66 | "not": [ |
| 67 | { |
| 68 | "path": [ |
| 69 | "*/" |
| 70 | ] |
| 71 | } |
| 72 | ] |
| 73 | } |
| 74 | ] |
| 75 | }, |
| 76 | { |
| 77 | "group": "group0", |
| 78 | "handle": [ |
| 79 | { |
| 80 | "handler": "rewrite", |
| 81 | "uri": "{http.matchers.file.relative}" |
| 82 | } |
| 83 | ], |
| 84 | "match": [ |
| 85 | { |
| 86 | "file": { |
| 87 | "split_path": [ |
| 88 | ".php" |
| 89 | ], |
| 90 | "try_files": [ |
| 91 | "{http.request.uri.path}", |
| 92 | "{http.request.uri.path}/index.php", |
| 93 | "index.php" |
| 94 | ] |
| 95 | } |
| 96 | } |
| 97 | ] |
| 98 | }, |
| 99 | { |
| 100 | "handle": [ |
| 101 | { |
| 102 | "handler": "reverse_proxy", |
| 103 | "transport": { |
| 104 | "protocol": "fastcgi", |
| 105 | "split_path": [ |
| 106 | ".php" |
| 107 | ] |
| 108 | }, |
| 109 | "upstreams": [ |
| 110 | { |
| 111 | "dial": "127.0.0.1:9000" |
| 112 | } |
| 113 | ] |
| 114 | } |
| 115 | ], |
| 116 | "match": [ |
| 117 | { |
| 118 | "path": [ |
| 119 | "*.php" |
| 120 | ] |
| 121 | } |
| 122 | ] |
| 123 | } |
| 124 | ] |
| 125 | } |
| 126 | ] |
| 127 | } |
| 128 | ] |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | } |