Running PiHole with Apache2
I'm trying to install PiHole on my Raspberry Pi, but having some trouble configuring it. I currently use it as a reverse proxy to some webservers/applications running in my network. My main issue (I think) is because I use Cloudflare, I need to use port 80 (since I can't specify an A record with a port).
So I'm hoping there is some way of replacing lighttpd with my existing Apache instance. What I would like to do:
- Keep Cloudflare pointing at my static IP address, so port 80 will hit my reverse proxy
- Configure my router to use the local IP of my Raspberry PI (192.168.xxx.xxx) as the DNS server
Here is my current vhosts:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html
ServerName subdomain.mydomain.com
ServerAlias subdomain.mydomain.com
ProxyPass / http://192.168.xxx.xxx:8080/
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html
ServerName subdomain2.mydomain.com
ServerAlias subdomain2.mydomain.com
ProxyPass / http://192.168.xxx.xxx:9000/
</VirtualHost>
<!-- A few more entries with different ports/subdomains -->
I'm currently running PiHole in a docker container, but that can be changed if required. I've made no configuration changes to PiHole.
Thanks!
Solution 1:
It seems you have a fundamental misunderstanding of how DNS works. DNS always works on port 53 (UDP/TCP). Anything you're doing with the reverse proxy or Cloudflare will only work for HTTP protocol (such as the PiHole web server, used to configure and monitor PiHole). The PiHole DNS service will only work on port 53.
If you want to use PiHole on your local network, set the DNS settings on devices in your network to the IP address of your Pi.
If you want to use your PiHole across the internet, read a couple of guides on the dangers of running an open resolver on the internet.