mirror of
https://github.com/caddyserver/caddy.git
synced 2025-07-09 03:04:57 -04:00
Destroyed v2: Config from Scratch (markdown)
parent
41f1e3d3d4
commit
419b4f240e
@ -1,72 +0,0 @@
|
|||||||
An empty config does nothing:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{}
|
|
||||||
```
|
|
||||||
|
|
||||||
This is an empty HTTP server, which responds on port 80 to any host, but with an empty response:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"apps": {
|
|
||||||
"http": {
|
|
||||||
"servers": {
|
|
||||||
"myserver": {
|
|
||||||
"listen": [":80"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
This is a static file server out of the the `/var/www` directory:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"apps": {
|
|
||||||
"http": {
|
|
||||||
"servers": {
|
|
||||||
"myserver": {
|
|
||||||
"listen": [":80"],
|
|
||||||
"routes": [
|
|
||||||
{
|
|
||||||
"handle": [{
|
|
||||||
"handler": "file_server",
|
|
||||||
"root": "/var/www"
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
And this is the same, but with automatic HTTPS (notice that we now serve on the HTTPS port; any port will do, as long as it's not the HTTP port):
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"apps": {
|
|
||||||
"http": {
|
|
||||||
"servers": {
|
|
||||||
"myserver": {
|
|
||||||
"listen": [":443"],
|
|
||||||
"routes": [
|
|
||||||
{
|
|
||||||
"match": [{"host": ["example.com"]}],
|
|
||||||
"handle": [{
|
|
||||||
"handler": "file_server",
|
|
||||||
"root": "/var/www"
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
The reason this particular config gets automatic HTTPS is because the host matcher informs Caddy which hostnames to manage certificates for.
|
|
Loading…
x
Reference in New Issue
Block a user