diff --git a/v2:-Caddyfile-examples.md b/v2:-Caddyfile-examples.md index 68b00fb..665e835 100644 --- a/v2:-Caddyfile-examples.md +++ b/v2:-Caddyfile-examples.md @@ -129,4 +129,138 @@ The converted equivalant (_./caddy adapt-config --input /path/to/Caddyfile --ada } } } +``` + +## Simple FQDN static fileserver with php support and automatic HTTPS +Configuring Caddy as a simple and FQDN static HTTP fileserver that can also run PHP with automatic HTTPS can look like this: +``` +{ + handler_order appearance +} + +yourdomain.com, www.yourdomain.com { + +root * /path/to/webfolder + +encode gzip + +php_fastcgi unix//path/to/php.sock + +file_server + +} +``` +The converted equivalant (_./caddy adapt-config --input /path/to/Caddyfile --adapter caddyfile --pretty_) in json looks like this: +``` +{ + "apps": { + "http": { + "servers": { + "srv0": { + "listen": [ + ":443" + ], + "routes": [ + { + "match": [ + { + "host": [ + "yourdomain.com", + "www.yourdomain.com" + ] + } + ], + "handle": [ + { + "handler": "subroute", + "routes": [ + { + "handle": [ + { + "handler": "vars", + "root": "/path/to/webfolder" + }, + { + "handler": "subroute", + "routes": [ + { + "handle": [ + { + "encodings": { + "gzip": {} + }, + "handler": "encode" + } + ] + }, + { + "handle": [ + { + "handler": "rewrite", + "rehandle": true, + "uri": "{http.matchers.file.relative}{http.request.uri.query_string}" + } + ], + "match": [ + { + "file": { + "try_files": [ + "{http.request.uri.path}", + "index.php" + ] + } + } + ] + }, + { + "handle": [ + { + "handler": "reverse_proxy", + "transport": { + "protocol": "fastcgi", + "split_path": ".php" + }, + "upstreams": [ + { + "dial": "unix//path/to/php.sock" + } + ] + } + ], + "match": [ + { + "path": [ + "*.php" + ] + } + ] + }, + { + "handle": [ + { + "handler": "file_server", + "hide": [ + "Caddyfile" + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + } + }, + "tls": { + "automation": {}, + "session_tickets": {} + } + } +} ``` \ No newline at end of file