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
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
The html file that PiHole (DNSmasq) uses is located:
/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:
#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.
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?
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:
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:
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)
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.
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.
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-end owner=dietpi application=pihole service=dnsserverJust a hint.
Grtz, F.C.