Æ

Temporarily disable Pi-hole with an Apple Shortcut

June 25, 2023

Setting up Pi-hole on my home network is one of the best quality-of-life improvements I’ve made to my browsing experience. I don’t know the last time I’ve seen a display ad on a website except for the time my Raspberry Pi needed a hard restart after a power outage. Adding PIVPN to allow my mobile devices to connect through my home network enables no-fuss ad blocking when I’m away from home, but that’s another story.

My only complaint about Pi-hole, and it’s not really an issue with the softwar itself, is that some websites and streaming services will not load at all when ad blocking is active (Looking at you Paramount+). I doubt these culprits will change their user-hostile ways, so I have to temporarily disable ad blocking to get a video started. After that, the stream seems to work just fine. Doing all this can be a cumbersome process, so I had an idea to begin using Apple Shortcuts to make this a 1-click affair.

Pi-hole API

Pi-hole provides an API to perform a limited number of operations without the need to sign into the web app. Thankfully, one of those operations is disable. It’s a straightforward command that can be called with GET.

curl http://<YOUR_PIHOLE_DOMAIN>/admin/api.php?auth=<YOUR_PIHOLE_API_TOKEN>?disable=<DURATION_IN_SECONDS>

The API token can be found in your Pi-hole settings shown below.

Pi-hole API settings

You can choose any arbitrary duration in seconds. Five minutes (300 seconds) is typically sufficient.

Apple Shortcuts

Now for the magic!

Open up the Shortcuts app on your Mac, iPhone or iPad and create a new shortcut. Add a new “Get Contents of URL” step and enter the API URL you created above.

Creating the Shortcut

Do a test run and check your Pi-hole web admin. If you did everything correctly, you’ll see that ad blocking is disabled temporarily.

Now that the shortcut has been created, you can add a widget to your iOS device homescreens for a one-click operation.


Profile picture

Written by Aaron Eaton