From 08cc8a0b0a83398332bad1737614f64e8214b45d Mon Sep 17 00:00:00 2001 From: Anoop B Date: Wed, 29 Apr 2020 15:20:05 +0530 Subject: [PATCH 1/4] ADD DOCS FOR CADDY-2 --- docs/guides/caddy-configuration.md | 33 ++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/docs/guides/caddy-configuration.md b/docs/guides/caddy-configuration.md index 47ade52..16771d6 100644 --- a/docs/guides/caddy-configuration.md +++ b/docs/guides/caddy-configuration.md @@ -2,6 +2,8 @@ If you'd like to use [Caddy](https://caddyserver.com/) as your main web server with Pi-hole, you'll need to make a few changes. +> Note: This guide only deals with setting up caddy as a reverse-proxy and not as a replacement for lighttpd (Although caddy is capable of doing so, but it is beyond the scope of this guide). + ## Modifying lighttpd configuration First, change the listen port in this file: `/etc/lighttpd/lighttpd.conf:` @@ -28,6 +30,8 @@ sudo service lighttpd restart 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. +### Caddyfile (Caddy Version 1) + ``` blackhole:80, pi.hole:80, 0.0.0.0:80 { root /var/www/html/pihole @@ -46,11 +50,35 @@ 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. -Finally, restart your Caddy server: `sudo service caddy restart` +### 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. ## Verifying your setup -First, make sure that any other sites you're serving from caddy are still functioning. For example, if you have a block for `myawesomesite.com:80` in your Caddyfile, open up a browser to `http://myawesomesite.com` and verify it still loads. +First, make sure that any other sites you're serving from caddy are still functioning. For example, if you have a block for `myawesomesite.com:80` or similar in your Caddyfile, open up a browser to `http://myawesomesite.com` (or `https://` if you have enabled it) and verify it still loads. Next, verify you can load the admin page. Open up `http://pi.hole/admin` (or use the IP address of your server) and verify that you can access the admin page. @@ -75,3 +103,4 @@ Lastly, ensure that requests for JavaScript files from advertisement domains are 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/). \ No newline at end of file From b3b08c4ea7945f54fd10b8a4a1c3dfa5acd2b79a Mon Sep 17 00:00:00 2001 From: Anoop B Date: Wed, 29 Apr 2020 15:34:50 +0530 Subject: [PATCH 2/4] fix linting --- docs/guides/caddy-configuration.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/guides/caddy-configuration.md b/docs/guides/caddy-configuration.md index 16771d6..a319cab 100644 --- a/docs/guides/caddy-configuration.md +++ b/docs/guides/caddy-configuration.md @@ -51,13 +51,15 @@ 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. +- 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 @@ -66,7 +68,9 @@ 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 @@ -74,7 +78,7 @@ encode zstd gzip } ``` -Finally, run `sudo systemctl daemon-reload` to force caddy to load the new configuration. +Finally, run `sudo systemctl daemon-reload` to force caddy to load the new configuration. ## Verifying your setup @@ -103,4 +107,5 @@ Lastly, ensure that requests for JavaScript files from advertisement domains are 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/). \ No newline at end of file + +For more information visit caddy's documentation [website](https://caddyserver.com/docs/). From 081cb06b239fd1724c2ad15ea5a64d0f000e5b75 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Thu, 30 Apr 2020 16:22:36 +0300 Subject: [PATCH 3/4] 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 a319cab..7b1a607 100644 --- a/docs/guides/caddy-configuration.md +++ b/docs/guides/caddy-configuration.md @@ -65,7 +65,7 @@ The following configuration will automatically fetch and setup Https for your do ``` myawesomesite.com { -reverse_proxy localhost:1080 + reverse_proxy localhost:1080 } ``` @@ -73,8 +73,8 @@ Additionally you can make pihole reacheable via a subdomain and optionally can y ``` pihole.myawesomesite.com { -reverse_proxy localhost:1080 -encode zstd gzip + reverse_proxy localhost:1080 + encode zstd gzip } ``` From 3b878dfe7d31cb278dd389e34e6ed1fd83dfd5e4 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Thu, 30 Apr 2020 16:23:02 +0300 Subject: [PATCH 4/4] Update caddy-configuration.md --- docs/guides/caddy-configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/caddy-configuration.md b/docs/guides/caddy-configuration.md index 7b1a607..71940ac 100644 --- a/docs/guides/caddy-configuration.md +++ b/docs/guides/caddy-configuration.md @@ -88,7 +88,7 @@ Next, verify you can load the admin page. Open up `http://pi.hole/admin` (or use Finally, verify that requests for ads are being black holed: -```bash +```console $ curl -H "Host: badhost" pi.hole/