diff --git a/v2:-Config-from-Scratch.md b/v2:-Config-from-Scratch.md new file mode 100644 index 0000000..113821a --- /dev/null +++ b/v2:-Config-from-Scratch.md @@ -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. \ No newline at end of file