ADD DOCS FOR CADDY-2

This commit is contained in:
Anoop B
2020-04-29 15:20:05 +05:30
parent 71a3fd902b
commit 08cc8a0b0a
+31 -2
View File
@@ -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/).