mirror of
https://github.com/caddyserver/caddy.git
synced 2025-11-26 00:05:21 -05:00
Created v2: Config from Scratch (markdown)
parent
adb5afee39
commit
fb3a9aed0f
75
v2:-Config-from-Scratch.md
Normal file
75
v2:-Config-from-Scratch.md
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
Empty config (does nothing):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Empty HTTP server (responds with empty responses):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"apps": {
|
||||||
|
"http": {
|
||||||
|
"servers": {
|
||||||
|
"myserver": {
|
||||||
|
"listen": [":80"],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Static file server out of the current directory:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"apps": {
|
||||||
|
"http": {
|
||||||
|
"servers": {
|
||||||
|
"myserver": {
|
||||||
|
"listen": [":80"],
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"respond": {
|
||||||
|
"responder": "file_server"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Same as above, but with automatic HTTPS (including HTTP->HTTPS redirects):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"apps": {
|
||||||
|
"http": {
|
||||||
|
"servers": {
|
||||||
|
"myserver": {
|
||||||
|
"listen": [":443"],
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"match": [
|
||||||
|
{
|
||||||
|
"host": ["example.com"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"respond": {
|
||||||
|
"responder": "file_server"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The reason the above config uses HTTPS is because the host matcher informs Caddy which hostnames to manage certificates for.
|
||||||
Loading…
x
Reference in New Issue
Block a user