Pi Hole Blank Page Loading?

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
rothchild
Posts: 74
Joined: Sat Jun 27, 2015 10:39 am

Pi Hole Blank Page Loading?

Post by rothchild »

In the DP installation of PiHole how do I set it up to load a blank page (tiny image) to replace the ads that have been blocked? The guidance on the Pi Hole site talks about Lighttpd but this version is running on apache?

Cheers,
Child
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: Pi Hole Blank Page Loading?

Post by Fourdee »

rothchild wrote:In the DP installation of PiHole how do I set it up to load a blank page (tiny image) to replace the ads that have been blocked?
Cheers,
Child
The html file that PiHole (DNSmasq) uses is located:

Code: Select all

/var/www/index.html
If you want to send all blocked traffic to the webpage, you will need to commit your webserver to that task:

Code: Select all

#Pi-hole ------------------------------------------------------------------
#Redirect all webtraffic to index.html.
# - Ensures redirect 301 code instead of 404 when a "non-"index.html filepath is used (eg: www.myblockedsite.com/folder1/page.html)
cat << _EOF_ > /var/www/.htaccess
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/index.html
RewriteCond %{REQUEST_URI} !=/apc.php
RewriteRule ^ /index.html [R=301]
_EOF_

#Allow overrides and redirects
sed -i "/AllowOverride/c\AllowOverride All" /etc/apache2/sites-enabled/000-default*
#+Jessie
sed -i "/AllowOverride/c\AllowOverride All" /etc/apache2/apache2.conf

#Enable apache2 rewrite engine
a2enmod rewrite

#Restart service
service apache2 restart

#Enable dns-nameservers for your adapter in /etc/network/interfaces
# eg: dns-nameservers 8.8.8.8 8.8.4.4
#Pi-hole END-------------------------------------------------------------
The guidance on the Pi Hole site talks about Lighttpd but this version is running on apache?
DietPi uses Apache for all webserver based software installations.
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
rothchild
Posts: 74
Joined: Sat Jun 27, 2015 10:39 am

Re: Pi Hole Blank Page Loading?

Post by rothchild »

Thanks,

I must have screwed it up somehow, I've now got the 'blocked by pi hole' page when I try to log in to the /pihole admin page.

I'm going to try a fresh install.

Will the fact that I'm using the root index page cause me trouble hosting an owncloud server on the same machine?
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: Pi Hole Blank Page Loading?

Post by Fourdee »

rothchild wrote:Will the fact that I'm using the root index page cause me trouble hosting an owncloud server on the same machine?
All DietPi software (excluding PiHole) that uses a webserver stack will install that software to its own subdirectory, or, use a specific port. This allows for multiple uses of your webserver in DietPi. eg:
- Owncloud /var/www/owncloud = http://dietpi/owncloud
- SubSonic :9000 = http://dietpi:9000

If you have enabled the code in my previous post titled "send all blocked traffic to the webpage", this will forward all webserver traffic to /var/www/index.html (the PiHole webpage). Including owncloud, in effect, disabling it.

PiHole works by sending any blocked hit to the exact same path on your webserver. eg:

- I goto http://www.blockedsite.com/test/test.html
- PiHole blocks the domain blockedsite.com
- PiHole will then redirect to your webserver http://localhost/test/test.html
- As http://localhost/test/test.html does not exist on your webserver, it will generate a 404 error.
- Using "send all blocked traffic to the webpage" will forward to http://localhost/index.html (the "blocked by PiHole webpage)

So you only need "send all blocked traffic to the webpage" if you want to redirect all PiHole blocks that have a url path different to http://www.blockedsite.com to index.html, instead of a 404 error. However, as above, this will disable all other uses for your webserver (eg: owncloud)
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
FedoraCore

Re: Pi Hole Blank Page Loading?

Post by FedoraCore »

The problem(s) with the webhost(s) for the Pi-Hole can be solved.
Why not define a separate static IP address (using interface alias eth0:1) for the Pi-Hole DNSMasq Server.
And another separate static IP address (using interface alias eth0:2) for the Apache VirtualHost for the Pi-Hole adblock server.
And another separate static IP address (using interface alias eth0:3) for the Apache VirtualHost for the Pi-Hole AdminLTE server.
And another separate static IP address (using interface alias eth0:4) for the SSH connection for the Pi-Hole Logstalgia GUI.
Only the Apache2 config file for the Pi-Hole adblock server needs a RewriteRule. (Not in .htaccess --- config is parsed once, .htaccess is parsed for each request - chapter 4 O'Reilly)
A new Apache2 config file for the VirtualHost for the Pi-Hole admin server is required.
Bonus : separate error-logs and access-logs for both VirtualHosts may be defined.
Modification of the Pi-Hole script is required, to replace the dynamic search for the IP address with a static value.

Why will this be needed in the future?
Well, the developer of the Pi-Hole software plans to use the admin website for maintenance.
This will mean that you will be able to start the script for updating the DNS configs, from the admin page.
This will also mean that you will be able to add a domain to the whitelist, from the admin page.

Grtz, F.C.
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: Pi Hole Blank Page Loading?

Post by Fourdee »

FedoraCore wrote:The problem(s) with the webhost(s) for the Pi-Hole can be solved.
Why not define a separate static IP address (using interface alias eth0:1) for the Pi-Hole DNSMasq Server.
And another separate static IP address (using interface alias eth0:2) for the Apache VirtualHost for the Pi-Hole adblock server.
And another separate static IP address (using interface alias eth0:3) for the Apache VirtualHost for the Pi-Hole AdminLTE server.
And another separate static IP address (using interface alias eth0:4) for the SSH connection for the Pi-Hole Logstalgia GUI.
Only the Apache2 config file for the Pi-Hole adblock server needs a RewriteRule. (Not in .htaccess --- config is parsed once, .htaccess is parsed for each request - chapter 4 O'Reilly)
A new Apache2 config file for the VirtualHost for the Pi-Hole admin server is required.
Bonus : separate error-logs and access-logs for both VirtualHosts may be defined.
Modification of the Pi-Hole script is required, to replace the dynamic search for the IP address with a static value.
Interesting method.

The only downside is the additional eth0:x adapters in /etc/network/interfaces, as DietPi-Config > Networking > Ethernet/Wifi is not currently designed to handle them. It expects lo/ethx/wlanx in the config, any "advanced" changes (eg eth0:x additions) would render DietPi-Config > Networking > Ethernet/Wifi unstable and should be avoided.
Why will this be needed in the future?
Well, the developer of the Pi-Hole software plans to use the admin website for maintenance.
This will mean that you will be able to start the script for updating the DNS configs, from the admin page.
This will also mean that you will be able to add a domain to the whitelist, from the admin page.
Sounds good, especially the whitelist/blacklist control. Be interesting to see how far they take the webstats page.
Also to the IT guys from the multi-million dollar advertising industry that we sabotage.
Lets not make it easier for them, considering most adverts completely abuse the browsing experience. :)
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
FedoraCore

Re: Pi Hole Blank Page Loading?

Post by FedoraCore »

Fourdee wrote: The only downside is the additional eth0:x adapters in /etc/network/interfaces, as DietPi-Config > Networking > Ethernet/Wifi is not currently designed to handle them. It expects lo/ethx/wlanx in the config, any "advanced" changes (eg eth0:x additions) would render DietPi-Config > Networking > Ethernet/Wifi unstable and should be avoided.
I agree with your observation completely.
The DietPi-Config is indeed used for the Raspberry-Pi itself, and for good behaving applications, for example to connect to a head-less Raspberry-Pi with SSH.

For some very special applications, like the Pi-Hole, "advanced" Interface Aliasses can be created on a "per-application" basis by an "application-installer-helper-script".
With conventional comment structures (°) to identify them in the /etc/network/interfaces.
Note: if /etc/init.d can use conventional comments ( for chkconfig: ), then so can we. ;-)

(°) For example:
  • # block-start owner=dietpi application=pihole service=dnsserver
    <statements>
    # block-end owner=dietpi application=pihole service=dnsserver

    # block-start owner=dietpi application=pihole service=webserver website=adblock
    <statements>
    # block-end owner=dietpi application=pihole service=webserver website=adblock

    # block-start owner=dietpi application=pihole service=webserver website=admin
    <statements>
    # block-end owner=dietpi application=pihole service=webserver website=admin

    # block-start owner=dietpi application=pihole service=sshserver
    <statements>
    # block-end owner=dietpi application=pihole service=sshserver
Just a hint. ;-)

Grtz, F.C.
Post Reply