Hi,
first of all, thanks to all those involved in the development of PiHole - this is just so great!
Secondly, I've done a lot of reasearch before deciding to finally post. In short, this is my situation:
- PiHole running on a RaspberryPi at IP
192.168.1.10and acting as DHCP and DNS server - the DNS server is "recursive" and uses Unbound as specified in this guide: unbound - Pi-hole documentation - Self-hosted services running in Docker containers on another Linux machine at IP
192.168.1.15(behind a reverse proxy) - The reverse proxy on the Linux machine residing 192.168.1.15 can be reached from outside the local network thanks to Cloudflare tunnel (I've used this solution to avoid port forwarding)
- I've also configured Wireguard VPN running on an OpenWrt router (subnet
10.14.0.0)
The "issue" is very simple: one of the self-hosted services is a music streaming service reachable via Cloudflare tunnel at (e.g.) "music.myserver.com".
This works fine when I'm outside the local network but it is a "PITA" when I am in the local network: streamed music must go through Cloudflare tunnel and, given my poor upload speed (minimum guaranteed bandwith 0,512 Mbps)...it is very slow.
Therefore I would like that requests to "music.myserver.com" are replied with:
- the reverse proxy address when I am in the local network, to avoid using Cloudflare tunnel
- the DNS provided by Cloudflare when I am outside the local network (with or without VPN) so I can reach my reverse proxy through Cloudflare tunnel
At first I've tried configuring Local DNS Records on PiHole in order to point "music.myserver.com" to the reverse proxy at 192.168.1.15. This works fine, but now we put Wireguard VPN in the equation.
Basically, I setup Wireguard on my Android phone so that, when I am out of the local network, DNS requests get forwarded to PiHole running on 192.168.1.10. Again, this works.
The issue is that when I try to access "music.myserver.com" outside the local network through the VPN, the DNS request through Wireguard is forwarded to PiHole, which in turn replies with the IP of the reverse proxy on 192.168.1.15.
Since I use Wireguard VPN only for DNS requests and not for "all network traffic" (again, slow upload speed), of course I cannot access the reverse proxy and thus the music streaming service.
I've found another topic with a situation similar to mine: Conditional DNS Resolution for Home Server Access from Local Network and VPN
Thus, I've tried configuring Unbound with DNS views.
Specifically I've edited Unbound default configuration at /etc/unbound/unbound.conf.d/pi-hole.conf and added:
server:
.... default config found in the guide....
access-control-view: 192.168.1.0/24 local-view
view:
name: "local-view"
local-zone: "music.myserver.com" redirect
local-data: "music.myserver.com A 192.168.1.15"
Unfortunately, above configuration doesn't work.
Pings to "music.myserver.com" are always replied with Cloudflare IPs, notwithstanding the network I am in (local/VPN/without VPN).
I am most probably missing something, but I cannot understand what.
That is why I am asking for your help.