From dd9297db51d65a0d7951ad78f1203cc8dff44e84 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 14 May 2020 11:10:40 -0400 Subject: [PATCH 1/2] Update caddy-configuration.md --- docs/guides/caddy-configuration.md | 76 +++++++++++++++++------------- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/docs/guides/caddy-configuration.md b/docs/guides/caddy-configuration.md index 71940ac..de3ce86 100644 --- a/docs/guides/caddy-configuration.md +++ b/docs/guides/caddy-configuration.md @@ -26,11 +26,47 @@ or sudo service lighttpd restart ``` +## Installing Caddy + +Follow the instructions on the [Caddy download](https://caddyserver.com/docs/download) documentation page. + ## Setting up your Caddyfile -Now set up a "virtual host" in your Caddyfile (default `/etc/caddy/Caddyfile`). There are many options you can add, but at a minimum, you need to make a "default" host by binding `0.0.0.0:80`. This will accept requests for any interface. +Now set up a "virtual host" in your Caddyfile (default `/etc/caddy/Caddyfile`). There are many options you can add, but at a minimum, you need to make a "default" host by binding `:80`. This will accept requests for any interface on port `80`. -### Caddyfile (Caddy Version 1) +### Caddyfile (for Caddy v2) + +``` +http://pi.hole:80 { + reverse_proxy localhost:1080 +} +``` + +- If you'd like to enable Https on your site, make sure your server is reachable via your domain name (ex: myawesomesite.com) and is pointing to the right IP address. +- Additionally you need to open ports :80 and :443 (Apart from the one's required specifically for pi-hole) for your server before setting up https. + +The following configuration will automatically fetch and setup HTTPS for your domain using Lets-Encrypt + +``` +myawesomesite.com { + reverse_proxy localhost:1080 +} +``` + +Additionally you can make pihole reacheable via a subdomain and optionally can you enable Zstandard and Gzip compression as follows: + +``` +pihole.myawesomesite.com { + reverse_proxy localhost:1080 + encode zstd gzip +} +``` + +Finally, run `sudo systemctl caddy reload` to reload Caddy with the new configuration. + +### Caddyfile (for Caddy v1) + +Caddy v1 is no longer actively supported, but the following is a config example if you're running an old installation. ``` blackhole:80, pi.hole:80, 0.0.0.0:80 { @@ -48,37 +84,7 @@ blackhole:80, pi.hole:80, 0.0.0.0:80 { } ``` -In this case, I've chosen to also add blackhole and pi.hole as valid names to open the admin page with. - -### Caddyfile (Caddy version 2) - -``` -pi.hole:80{ - reverse_proxy localhost:1080 -} -``` - -- If you'd like to enable Https on your site, make sure your server is reacheable via your domain name (ex: myawesomesite.com) and is pointing to the right IP address. -- Additionally you need to open ports :80 and :443 (Apart from the one's required specifically for pi-hole) for your server before setting up https. - -The following configuration will automatically fetch and setup Https for your domain using Lets-Encrypt - -``` -myawesomesite.com { - reverse_proxy localhost:1080 -} -``` - -Additionally you can make pihole reacheable via a subdomain and optionally can you enable Zstandard and Gzip compression as follows: - -``` -pihole.myawesomesite.com { - reverse_proxy localhost:1080 - encode zstd gzip -} -``` - -Finally, run `sudo systemctl daemon-reload` to force caddy to load the new configuration. +In this example, `blackhole` and `pi.hole` are added as valid names with which to open the admin page. ## Verifying your setup @@ -108,4 +114,6 @@ curl -H "Host: badhost" pi.hole/malicious.js var x = "Pi-hole: A black hole for Internet advertisements." ``` -For more information visit caddy's documentation [website](https://caddyserver.com/docs/). +For more information visit Caddy's documentation [website](https://caddyserver.com/docs/). + +For usage questions or support, visit the [Caddy Community forums](https://caddy.community/). From 61f47c8f50c2775ef7d87c8094cdc83815f784b9 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 14 May 2020 11:14:38 -0400 Subject: [PATCH 2/2] Update caddy-configuration.md --- docs/guides/caddy-configuration.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/guides/caddy-configuration.md b/docs/guides/caddy-configuration.md index de3ce86..9f49317 100644 --- a/docs/guides/caddy-configuration.md +++ b/docs/guides/caddy-configuration.md @@ -37,13 +37,13 @@ Now set up a "virtual host" in your Caddyfile (default `/etc/caddy/Caddyfile`). ### Caddyfile (for Caddy v2) ``` -http://pi.hole:80 { +http://pi.hole { reverse_proxy localhost:1080 } ``` -- If you'd like to enable Https on your site, make sure your server is reachable via your domain name (ex: myawesomesite.com) and is pointing to the right IP address. -- Additionally you need to open ports :80 and :443 (Apart from the one's required specifically for pi-hole) for your server before setting up https. +- If you'd like to enable HTTPS on your site, make sure your server is reachable via your domain name (ex: myawesomesite.com) and is pointing to the right IP address. +- Additionally you need to open ports :80 and :443 (Apart from the one's required specifically for pi-hole) for your server before setting up HTTPS. The following configuration will automatically fetch and setup HTTPS for your domain using Lets-Encrypt