WaLLy3K / Pi-hole-Block-Page

A "Website Blocked" page to go with https://pi-hole.net
MIT License
120 stars 12 forks source link
customisation pi-hole

This project is discontinued as of Pi-hole v3.2

If you would like to implement a custom block page, it is recommended to create a file called /var/www/html/pihole/custom.php and use that instead. You may uninstall this project using the following instructions:

html=$(grep server.document-root /etc/lighttpd/lighttpd.conf | awk -F\" '{print $2}')
sudo rm -rf $html/index.php /var/phbp.ini /etc/lighttpd/conf-enabled/phbp.conf
[ -f "/var/phbp.ini.BAK" ] && rm -f /var/phbp.ini.BAK
sudo service lighttpd force-reload

Pi-hole Block Page

A stylish and user friendly 'Website Blocked' page to add onto a Pi-hole installation.

What does this do?

The goal is to provide concise and relevant feedback to the end user, so they are better informed about the site they are trying to visit. This is very useful because an Internet connection is generally shared with a number of other people (and not just the person who set up Pi-hole on the network).

When a user browses to a blacklisted domain (For example, doubleclick.net), they will be presented with the block page as pictured below. This clearly shows what domain was blocked, what the most 'notable' list it was featured in, how they can go about resolving the issue and whether they would like to see more information.

In this case, doubleclick.net was found in https://s3.amazonaws.com/lists.disconnect.me/simple_malvertising.txt which has been classed as Tracking & Telemetry from within the definitions list.

Pi-hole Block Page

When a user (or site on the user's behalf) attempts to access any non HTML resource (i.e: not HTML, PHP, XML or RSS), the page will interpret this request as a 'file' and will show the following image:

Blocked by Pi-hole

If the 'Website Blocked' page is accessed through an iframe, a 1x1 transparent GIF will be shown (by default).

Finally: If a landing page has been specified by the Pi-hole admin, a user will be direct to that page if they enter the Pi-hole IP address (or domain name, if configured).

Customisation:

Everyone has different needs! Therefore, the admin of the Pi-hole Block Page has the ability to customise the following options:

Install & Update:

You will need to open up your preferred SSH client and enter the following commands:

[ -f "/var/phbp.ini" ] && sudo mv /var/phbp.ini /var/phbp.ini.BAK
html=$(grep server.document-root /etc/lighttpd/lighttpd.conf | awk -F\" '{print $2}')
sudo wget -q https://raw.githubusercontent.com/WaLLy3K/Pi-hole-Block-Page/master/index.php -O "$html/index.php"
sudo wget -q https://raw.githubusercontent.com/WaLLy3K/Pi-hole-Block-Page/master/phbp.ini -O "/var/phbp.ini"
sudo chmod 755 "$html/index.php"
[ -f "/var/phbp.php" ] && sudo mv /var/phbp.php /var/phbp.old.BAK
[ ! -d "/etc/lighttpd/conf-enabled" ] && sudo mkdir -m 755 /etc/lighttpd/conf-enabled
[ ! -f "/etc/lighttpd/conf-enabled/phbp.conf" ] && echo -e '# Pi-hole "server.error-handler-404" override\nurl.rewrite-once = ( "pihole/index.php" => "/index.php" )' | sudo tee /etc/lighttpd/conf-enabled/phbp.conf
echo "Done! Please edit '/var/phbp.ini' to customise your install"
sudo service lighttpd force-reload

This persists between Pi-hole updates, so you will only need to re-perform these commands when you see "Update Available" in the footer of the block page.

This script will not presume where the default document-root is, as installations such as DietPi are known to change this.

Uninstall:

If you would like to remove Pi-hole Block Page, you can enter the following via SSH:

html=$(grep server.document-root /etc/lighttpd/lighttpd.conf | awk -F\" '{print $2}')
sudo rm -rf $html/index.php /var/phbp.ini /etc/lighttpd/conf-enabled/phbp.conf
[ -f "/var/phbp.ini.BAK" ] && rm -f /var/phbp.ini.BAK
sudo service lighttpd force-reload

Website Test Cases:

Troubleshooting:

If you are having any issues with Pi-hole Block Page, please open a new ticket so it can be checked out. If necessary, include the output of either ?debug or ?debug=conf (e.g: http://doubleclick.net?debug=conf).

Postscript:

I am more than happy to take on board suggestions and feature requests, through the issues tracker. On top of this, you are welcome to modify and adapt this project as you see fit. However, please remember that the name 'Pi-hole', the vortex logo, 'boxed-bg.jpg' and Javascript whitelisting code remains property of Pi-hole, LLC.