diff --git a/v2:-Config-from-Scratch.md b/v2:-Config-from-Scratch.md index 49c9095..8c66385 100644 --- a/v2:-Config-from-Scratch.md +++ b/v2:-Config-from-Scratch.md @@ -1,78 +1,72 @@ -Empty config (does nothing): +An empty config does nothing: ```json {} ``` - -Empty HTTP server (responds with empty responses): +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"], - } - } - } - } + "apps": { + "http": { + "servers": { + "myserver": { + "listen": [":80"], + } + } + } + } } ``` -Static file server out of the specified directory: +This is a static file server out of the the `/var/www` directory: ```json { - "apps": { - "http": { - "servers": { - "myserver": { - "listen": [":80"], - "routes": [ - { - "respond": { - "responder": "file_server", - "root": "/var/www" - } - } - ] - } - } - } - } + "apps": { + "http": { + "servers": { + "myserver": { + "listen": [":80"], + "routes": [ + { + "respond": { + "responder": "file_server", + "root": "/var/www" + } + } + ] + } + } + } + } } ``` -Same as above, but with automatic HTTPS (including HTTP->HTTPS redirects): +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"] - } - ], - "respond": { - "responder": "file_server", - "root": "/var/www" - } - } - ] - } - } - } - } + "apps": { + "http": { + "servers": { + "myserver": { + "listen": [":443"], + "routes": [ + { + "match": [{"host": ["example.com"]}], + "respond": { + "responder": "file_server", + "root": "/var/www" + } + } + ] + } + } + } + } } - ``` -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 +The reason this particular config gets automatic HTTPS is because the host matcher informs Caddy which hostnames to manage certificates for.