Reverse proxy via apache to Pi-Hole admin interface

Hi all,

I'm trying to ease the access to Pi-Hole with a ... dns entry :stuck_out_tongue:
but it fails :frowning:
I get a message prompted "Blocked by Pi-Hole"

Idea

To keep it simple, I run Pi-Hole on port 807 and on the debian server I have apache2 on the same server that handles all reverse proxies.
Later I will use Apache as main webserver but now I want to learn about the reverse proxies.
I want dns.homenetwork.lan to internally proxy to 192.168.2.7:807/admin and present the Pi-Hole admin page.

Situation

PiHole is set as DNS server on the network and the internal DNS on the router is the first DNS entry for Pi-Hole, then the OpenDNS servers.
I have a local entry dns.homenetwork.lan that points in the DNS server from the router to 192.168.2.7.

The lighttp server is set to port 807 with the change of
server.port = 807

Testing 192.168.2.7:807/admin gives with a full working Pi-Hole admin interface.

Then I installed Apache and activated the reverse proxy modules.

I made a config file as follows, enabled the site and reloaded apache.
<VirtualHost *:80>
ServerAdmin dns@homenetwork.lan
ServerName dns.homenetwork.lan
DefaultType text/html
ProxyRequests off
ProxyPreserveHost Off
ProxyPass / http://192.168.2.7:807/admin/index.php
ProxyPassReverse / http://192.168.2.7:807/admin/index.php
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

When I surf to dns.homenetwork.lan, the page is redirected to dns.homenetwork.lan/admin but the message 'Blocked by Pi-hole' is presented.

Looking further I find in the error files fron pi-hole:
2018-03-18 13:03:06: (mod_fastcgi.c.2543) FastCGI-stderr: PHP Warning: file(http://127.0.0.1/admin/scripts/pi-hole/php/queryads.php?domain=dns.homenetwork.lan&bp): failed to open stream: HTTP request failed! in /var/www/html/pihole/index.php on line 136
2018-03-18 13:03:06: (mod_fastcgi.c.2543) FastCGI-stderr: PHP Warning: array_filter() expects parameter 1 to be array, string given in /var/www/html/pihole/index.php on line 137
2018-03-18 13:03:06: (mod_fastcgi.c.2543) FastCGI-stderr: PHP Warning: array_values() expects parameter 1 to be array, null given in /var/www/html/pihole/index.php on line 137

Analyzing this, I see there is no indication of port 807.
Manually entering
http://192.168.2.7:807/admin/scripts/pi-hole/php/queryads.php?domain=dns.homenetwork.lan
gives me feedback that it is found in the whitelist (where I placed it earlier assuming that was the error).

So, I think this is php related. Can somebody help me?

IMHO it should be possible to just reverse proxy from an apache server to a lighttp server on another port on the same server.

Mario

Even if you do get it to work, the web interface only allows certain hosts to access it (pi.hole, the device's hostname, the IP address, and a configurable host). At minimum you need to set the virtual host to the one you want to access it through.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.