Turn an Old Phone into a PiHole Disable Button

My PiHole runs on a network where I am not the only user, which I’d imagine is the case for most. I wanted a way to allow others on my network to temporarily disable PiHole so that they could access stuff like Google Shopping without needing me to manually disable it (or whitelist the ad servers that Google Shopping links run through).

I decided to build a rudimentary “disable” panel that I could run on an old device and mount somewhere. I used an iPhone 4s, but I’d imagine you could use any old touchscreen device with WiFi and a browser. I’ve posted the project to GitHub, and if you don’t need all the details you can head straight to that here: https://github.com/mattwebbio/pihole-disable-buttons

For the rest, here’s how to get it up and running yourself:

1. Install a Web Server

I’m running Nginx — if you host this script on your PiHole server, you can follow this tutorial with the following modifications:

  1. You don’t need SQL for this particular application — you can install this if you want, but otherwise skip this section.
  2. PiHole uses port 80, so you need to change the port Nginx is listening on — to do this, change listen 80 in /etc/nginx/sites-available/default to listen 8080 or similar.
  3. If you want a nicer looking hostname for the PiHole server (“pihole.lan” instead of “10.0.0.2”), you can set up an Nginx server block/virtual host using this tutorial and then make PiHole forward the matching DNS entry using step #2 of my tutorial here (if you don’t use Docker, just place these entries in a file in /etc/dnsmasq.d/).

2. Install the App

  1. Enter the directory where you want to host the app — if you installed Nginx as suggested above, this would be cd /var/www/ (and optionally mkdir FOLDERNAME && cd FOLDERNAME).
  2. Download the code: git clone https://github.com/mattwebbio/pihole-disable-buttons.git .
  3. Copy config.example.php to config.php and edit it: cp config.example.php config.php && nano config.php
  4. Enter your API URL and API key (the config file says where to find these — if you’re hosting on the same server, it’ll probably be http://127.0.0.1/admin/api.php).

3. Setup the Client Device

As I used an iPhone, I’ve got more information for iOS — but you can follow these directions loosely as you find fit.

  • Direct the web browser to where you’re hosting the panel — i.e. http://10.0.0.2:8080/ or http://10.0.0.2:8080/FOLDERNAME
  • Lock the screen to the browser and block browsing to other pages. I’m sure there are “kiosk” type apps that will allow you to do this on Android, but on iOS this can also be done with Guided Access:
  1. On iOS 9, disable screen timeout in Settings -> General -> Auto-Lock and set to “Never”.
  2. Enable Guided Access in Settings -> General -> Accessibility -> Toggle “Guided Access” and “Accessibility Shortcut”
  3. Go back to Safari, enter the panel address and click “go”
  4. Triple-click the home button to open Guided Access
  5. Click “Options” and disable all the unnecessary items (everything but “Touch”)
  6. Draw squares with your finger around the address bar and around the bottom bar (forward/back/tabs) — this will prevent the user from navigating away from the page.
  7. Click “Start” in the top right corner.

And done!

Show Comments

Get the latest posts delivered right to your inbox.