Customize Block Page

Block pages can only work for 404 and IP blocking mode. The page is pretty much going to go away as it does not work for https, Null blocking or NXDOMAIN blocking and the performance gain of Null/NX is so much that is makes the use of blocking pages a performance penalty.

Actually I got it working. The instructions were incorrect. BLOCKINGMODE=IP-NODATA-AAAA works. It works because the redirect created in that block mode goes to the IP address of the PI Hole which returns a 404 error and loads the custom page. The NULL does not because it returns an address of 0.0.0.0. I also copied image files to the custom block page location so that the images can be supplied locally. Image files referenced in the HTML must contain the folder address of "pihole/[imagename]". It works for all addresses including https. Although occasionally pi hole lags and the browser times out so the page dos not load (usually because the computer I'm using for the Pi Hole has gone into power save and doesn't wake up the HDD on time).

I'm using an old laptop - Dell Inspiron 2650 - for the Pi Hole.

The only trouble I'm having now is that the touchpad stopped working right after I started using a mouse. I've tried to fix it, but no success... Oh well, something for another thread.

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

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

  1. Create a folder in your documents folder called "CustomBlockPage".

  2. Copy the following files from the Pi-Hole web site into the folder:

https://pi-hole.net/wp-content/uploads/2016/12/Vortex-R.png (Logo)
https://piholenet.b-cdn.net/wp-content/uploads/2017/03/pihole-llc.png (Background)
  1. Open a terminal window with LXTerminal.

  2. Copy the image files to the Pi-Hole block page folder:

sudo cp /home/[Your user name]/Documents/CustomBlockPage/*.* /var/www/html/pihole
  1. Create an HTML file for your custom block page with the name "CustomBlockPage.htm" 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.htm
<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.htm
  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.htm"

Save and exit.

  1. Restart the lighttpd service:
sudo service lighttpd restart
  1. Change the blocking mode to "IP-NODATA-AAAA" in the "pihole-FTL.conf" file by adding a block mode line:
sudo nano /etc/pihole/pihole-FTL.conf

add this line:

BLOCKINGMODE=IP-NODATA-AAAA

Save and exit.

(Note: "IP-NODATA-AAAA" returns the IP address of the Pi-Hole as the page location. When Pi-Hole tries to load the page, it returns a 404 error and re-directs to the custom block page. Null returns an IP of 0.0.0.0 which will not help directing to the block page. "IP" and the other options also do not return a useful IP address for our purposes.)

  1. Restart the pihole-FTL service:
`sudo service pihole-FTL restart`

Congratulations, your block page is now ready.

Please Note: You may have to flush the DNS caches and browser cashes on the computers in your network for all the changes to take effect.

1 Like

So I have followed your instructions. Now rather than the normal page I get an "ERR_SSL_PROTOCOL_ERROR" on the pages i try to visit and not a block page.

I take it you are probably using Chrome. I don't use Chrome. Here is a troubleshooting article for Chrome related to the error: https://www.thesslstore.com/blog/fix-err-ssl-protocol-error/

A post was split to a new topic: Error with custom web page

Saving images in pihole folder is save for any future Pihole update? If not, what is the best approach to saving the images too?


Cool Thanks. Here is mine. I tried it 3 times and all after loading a block domain in url bar would download the file and not show the 404 page. It turns out that I only need to add the 'ip' to this line instead.

BLOCKINGMODE=IP

If you are using a bg image, most likely the image will not fill the entire screen on mobile and will tile to fill in the rest. Add these 2 lines to your css block if you are using a .css file.

background-size: cover;
background-repeat: no-repeat;

I followed all of your instructions and I got an 400 Bad Request as shown in an image instead of your custom block page
Please Help!!!
I am running pi-hole on debian

I did all the steps above and I still get the default block screen. Any ideas?

so this works fine in IE. However, if I launch a blocked site in Chrome it prompts a download dialog box with a file name "download".

Anyone else have this issue?

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.