Saturday 24 January 2015

Using my Mac Mini as an adblock proxy for my iPad

I really like my iPad. It's a wonderful tool for browsing the web, browsing media, reading stuff and controlling my home theatre PCs, whilst laying on the sofa or in bed. There's just one catch: No adblock, at least under Safari.

Now I don't know about you, but there's only so many "one weird tip" or "Ellen scandal" ads that I can cope with before going completely postal. The straw for me came in the form of a "vdopia" popup autoplaying video ad on mac rumours, which was not only incredibly irritating but also broke the mac rumours site.

In any case, I was desperate to find a way to browse the net on my iPad without having my eyes constantly burned out by incredibly obnoxious ads. I tried a couple of replacement browsers, but found they were even more obnoxious than the ads they blocked. The solution for me came in the form of privoxy, which is an adblocking proxy server.

This is where the new mac Mini comes in. The latest model (as well as having a huge 2TB hard drive for my media and super fast processor and video) draws a piddling 7W of mains power when idle, and are totally silent. I've had PCs that used more power than that when they were switched off. It's the perfect media server, and also the perfect proxy server.

So here's the secret sauce for getting privoxy running on new Macs running OS X Yosemite. It's based on instructions at Andrew Watters' blog with extensions to allow access from other machines on your local network (i.e. the iPads) and also to work around some Yosemite launchd weirdness:

1. Your mac needs to have a static IP address, so other machines on your network know where it is. I like to use my router to allocate IP addresses, so I set up a binding in there to ensure my mini always comes up at the same IP, but is still able to run DHCP. In my case, I run ifconfig from the terminal, and copy the mac address from the active interface, then paste that into the "DHCP reservations" field for my router using airport utility. I gave it a fixed IP of, which is easy to remember.

Note this isn't an address you can get to from the outside internet, as the router is still doing NAT. It's just for machines local to your router. Alas your eyes will still cop the obnoxious ads when you're away from your home network, but for me 90% of my net browsing is done at home, so this is good enough.

2. Now install Xcode from Apple. This is the apple software development suite, and includes compilers etc, which we'll use for compiling privoxy from source.

2a. You'll also need autoconf. The version linked to in Andrew's blog didn't work with the latest version of Xcode/os x, so I just found the newest version. From the terminal:

  • curl -OL
  • tar -xzf autoconf-2.69.tar.gz
  • cd autoconf-2.68
  • ./configure
  • make
  • sudo make install
I found I had to run it again from ./configure a second time because a fresh install of Xcode doesn't work until you've agreed to licence terms, which only come up when you make.

3. Add a user for privoxy, and associate them with a freshly created privoxy group.

4. Download the privoxy source, and install it:

  • cd ~/Downloads
  • tar -xzf privoxy-3.0.22-stable-src.tar
  • cd privoxy-3.0.22-stable-src
  • autoheader
  • autoconf
  • ./configure
  • make
  • sudo make install
5. Edit privoxy's config file:

  • sudo pico /usr/local/etc/privoxy/config
If you don't like pico, use whatever editor you prefer.

While you're in there, you need to change enable-remote-toggle to 1, enable-edit-actions to 1, and insert your IP address in place of the loopback at listen-address. Detailed instructions are on Andrew's blog

6. After much stuffing about, I worked out that launchd under Yosemite doesn't run the daemon when you use the RunAtLoad key. I found "KeepAlive" worked, and is more in keeping with what you want the OS to do with a daemon like this. So when you set up /Library/LaunchDaemon/org.privoxy.plist, substitute "KeepAlive" for "RunAtLoad"

7. Reboot to get the daemon running, and edit the proxy server setting on your iPad (settings->wifi) to manual, and enter the IP address of your mac, with port 8118.


Thanks Andrew, you're a champ!

1 comment:

Unknown said...

Actually it's easier than that (requires 10.9 or newer).

1) Install xCode (Mac App Store).
2) Install Command Line Tools for Xcode
3) Install Homebrew (
4) In type "brew install privoxy" and hit return.