From fb3a9aed0f0f9f0bca8573b8f6f8e16c540ff434 Mon Sep 17 00:00:00 2001 From: Matt Holt Date: Tue, 2 Jul 2019 16:12:27 -0600 Subject: [PATCH] Created v2: Config from Scratch (markdown) --- v2:-Config-from-Scratch.md | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 v2:-Config-from-Scratch.md 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