Add FQDN example with automatic HTTPS

Henrik 2019-09-12 10:36:28 +02:00
parent 57d38c3e76
commit f576c9e4cf

@ -130,3 +130,137 @@ 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": {}
}
}
}
```