This will also probably work on any other computer, smartphone or tablet that supports HTTP proxies.
Here Contains a Rant, You Won't Miss Anything by Skipping It
Don’t get me wrong I know that online advertising is the life blood of the internet, some sites are very expensive to run. The guys who run these sites deserve to be able to defray their costs, and if they can turn a profit by having something useful I think that is a great idea.
Not only that but I’ve found that advertising can actually be very useful. If I’m reading something and someone is advertising something that I would not of normally found out about then I think this is great. I’m being educated and I like that.
I’ve also ran online advertising campaigns for a number of clients, and found them to be excellent ways in which to highlight a product, or to enable you to enter a market. It’s a new world, and I embrace it.
However web designers and advertisers please make note of the following… When I am on a tablet device or a phone, and your adverts have not been formatted to work on my screen then guess what? You completely ruin my browsing experience.
Actually I can go as far as saying you can DESTROY by browsing experience quite easily. Let me explain. Some adverts on pages don’t like you scrolling in to their pages, literally. You scroll in and it may focus in the advert but it destroys the text I actually want to read. If at the same time you stop me from using the inbuilt “reader” function then I’m sorry but you’ve just lost what could have been a loyal reader.
Other sites put that many adverts down the side of the pages (you know I navigate by touching the screen right?) that I can’t instinctively scroll down through your site without clicking on an ad. A certain popular social network is a major guilty partner in this one.
I like non-obtrusive adverts, so we won’t be blocking them.
For this tutorial what you will need is a server running Ubuntu. We are going to install Squid, and use regular expressions to block adverts. We are also going to add a less intrusive replacement for the ads we will be removing. I used Ubuntu Server 11.10 for this tutorial and the excellent block lists over at http://pgl.yoyo.org
I’ll assume that you’ve got full root access too and will assume that your home network looks like this:
Subnet Mask 255.255.255.0
Ubuntu Server 192.168.0.100
Subnet Mask 255.255.255.0
Logon to your Ubuntu server and install Squid:
apt-get install squid
We’ll get the block lists sorted before we make the appropriate changes in the Squid configuration. Type in the following each on it’s own line
wget -O /etc/squid3/ad_block.acl “‘http://pgl.yoyo.org/adservers/serverlist.php?hostformat=squid-dstdom-regex&showintro=0&mimetype=plaintext”
wget -O /usr/share/squid3/errors/English/ERR_ADBLOCKED “‘http://www.gypthecat.com/stationary/ERR_ADBLOCKED”
Now let’s dive into the Squid configuration settings, but we won’t be doing too much, just enough to get our ad blocker working. We’ll also assume that your network settings look like the network settings above, if not change them accordingly.
Put the following lines at the top of the file.
acl localnet src 192.168.0.0/24
acl ads dstdom_regex “/etc/squid3/ad_block.acl”
http_access deny ads
http_access allow localnet
deny_info ERR_ADBLOCKED ads
Press [CTRL]+O (Save the file), then [CTRL]+X (Exists Nano).
Now lets restart Squid to make the changes we made.
service squid3 restart
Now lets make our iPad go through the proxy. Go to your Settings, Wifi, click the little Blue Arrow. Down the bottom select “Manual” and enter your details.
Proxy Server 192.168.0.100
Port 3128 (this is the default Squid port, if you changed it you will have to put it in here.)
Now you can surf away and most of the adverts that get in the way of your tablet surfing will be gone!
There are further steps you could take if fancy like putting further technology in place:
- Why not host this on a Linux VPS so you can block adverts regardless of how you have connected to the internet?
- (You will need to pay attention to security, may want to implement proxy HTTPS and probably will want to set Squid up with authentication.)
- When you get your Raspberry Pi why don’t you install the above on there for a low energy and low cost tailored proxy server?
- Why don’t you add additional block lists to keep your users safe?
Can you test this on any other smartphones or tablets and let me know if it works?