Customize Block Page

Hey all!
first time playing with the pi-hole and i really dont have much scripting skills.
Long story short i wanted to make sure that when something is blocked that my wife when working home will know its because of my "toys".. this way i can quickly fix it.

i followed the above guide however it didnt work well so i looked up another guide which suggested using php instead of htm..

Here are the refined instructions for my particular block page setup…

How to set up a custom block page in Pi-Hole:

  1. On the pi-hole go to the /var/www/html/pihole folder
  2. type the following:
wget https://pi-hole.net/wp-content/uploads/2016/12/Vortex-R.png
wget https://piholenet.b-cdn.net/wp-content/uploads/2017/03/pihole-llc.png
  1. Create an PHP file for your custom block page with the name “CustomBlockPage.php” and paste the HTML code in the file:
    (NOTE: Do not use LeafPad to make the file because it does not correctly format text for our purposes.)

sudo nano /var/www/html/pihole/CustomBlockPage.php

<HTML>
<TITLE>BLOCKED</TITLE>
<BODY BGCOLOR=000000 BACKGROUND="pihole/pihole-llc.png" TEXT=FFFFFF>
   <CENTER>
      <BR>
      <IMG SRC="pihole/Vortex-R.png" WIDTH=100><BR>
      <FONT Size=+2>
         <BR>
         This Page has Been Blocked<BR>
         *OR* Does not exist<BR>
      </FONT>
      <BR>
      Notice: Some pages have been blocked due to content or bandwidth restrictions.
      <BR>
      <BR>
      If you believe that this page has been blocked in error,<BR>please contact the front desk.
   </CENTER>
</BODY>
</HTML>

Save and close.

  1. Set your file’s permissions:

sudo chmod +x /var/www/html/pihole/CustomBlockPage.php

  1. Open the “lighttpd.conf” file to change the error handler for 404 file not found errors so that the custom block page opens instead of the default:

sudo nano /etc/lighttpd/lighttpd.conf

  1. Comment out the line “server.error-handler-404=“pihole/index.php”” with “#”, then add a new line with the custom block page file:
#server.error-handler-404="pihole/index.php"
server.error-handler-404="pihole/CustomBlockPage.php"

Save and exit.

  1. Restart the lighttpd service:

sudo service lighttpd restart

  1. Change the blocking mode to “IP” in the “pihole-FTL.conf” file by adding a block mode line:
    *note: I changed mine ti BLOCKINGMODE=IP its up to you
    Blocking modes options: https://docs.pi-hole.net/ftldns/blockingmode0/

sudo nano /etc/pihole/pihole-FTL.conf

  1. add this line:

BLOCKINGMODE=IP

Save and exit.

  1. Restart the pihole-FTL service:

sudo service pihole-FTL restart

Congratulations, your block page is now ready.

Thank you for sharing. The problem is that the 404 page will not work on google chrome, is there a way to fix it?

Look like I got bad request 400

Awsome solution; thanks for sharing -weird thing is that it doesnt seem to work for the Brave Browswer, i get:

This site can’t be reached

https://doubleclick.net/ is unreachable.

ERR_ADDRESS_UNREACHABLE

any ideas?

There's a small error in this line:

#server.error-handler-404="pihole/index.php"
server.error-handler-404="pihole/CustomBlockPage.php"

Instead it should be:
server.error-handler-404="/pihole/CustomBlockPage.php"

Then you shouldn't get a 400 - bad request.

A post was split to a new topic: Custom block page is not working with v5.0

For the website to be displayed correctly in Google Chrome, MS Edge, Opera, Vivaldi, Brave etc. browsers, you must change the extension from .htm to .html

I don't believe that is true. The webserver is the software that cares what the extension is.

It works for me in all browsers.

That's fine, the lighttpd configuration determines what file extensions it serves and what rendering engine is used to serve it.

Thanks to this post, I was able to setup my customized block page.
Any clue to get it working also for https?
I already own a nginx letsencrypt proxy with 80 and 443 ports open.
Defining the blocking page on it could be useful?

Thanks

Blockpages don't work on HTTPS/TLS. You can't impersonate a TLS site (without creating a Man-In-The-MIddle attack on yourself.)

Doesn't work with the current strategy. Other products out there are able to do it, a different strategy to solve this problem must exists.

Sure, create your own Certificate Authority (and all the associated security hardening required for it) and push that CA to all the devices browsers or certificate stores and you can do it.

The only way to impersonate a TLS site is to set up an authority that has implicit trust to impersonate ANY domain they want.

Sorry, I haven't been on here in a long time... Incase you didn't find an answer:
Someone suggested below that the following is missing a forward slash at the beginning of the file location:

server.error-handler-404="pihole/CustomBlockPage.htm"

This was assuming that Pi-Hole knows its own location in the drive structure. You can try modifying this to match the file structure of your installation to see if that helps.

Correct, it shouldn't care what extension, especially when ".htm" is part of the HTML standard. ".htm" was used because DOS and Windows 3.1 only supported 3 character file extensions. But it appears to no longer work in the newer version of pi-hole. Instead the page is served as a download instead of a viewable page. That sounds like a bug of some sort. I also found that the block page now only appears if you put in the Pi-Hole's IP address (and only when you change the extension to ".php"). Something has changed. (Correction... it does still work with an actual 404 error with the .php extension)

Please note: I don't know much about protocol standards so be kind :slight_smile:

Regarding blocking "https", at what point does the url lookup become encrypted? When I type in a url into my browser, I don't specifically type in an https. Shouldn't the block occur before the site has been determined to be an https site? Shouldn't any outside request be blocked through checking the block lists by url before determining if the site actually exists?

From the start. And if the domain is on the HSTS preload list or has been visited prior with HSTS headers then you won't be able to do the equivalent of a downgrade attack to disable the forced TLS.

Is anyone talking with Mozilla about legitimate DNS filtering and how it can be done with this new security concept? It sounds like it is going to undermine Pi-Hole's abilities completely.

No, it just means blockpages don't work. Which is fine, we plan to remove the feature anyways.

Edit: And STS is built in to TLS, there's no way it's coming out of being overridden.