martybugs.net SmoothwalL Express Info
 navigation
. MartyBugs home
. Smoothwall home
 
 Smoothwall info
. my box
. connect speed display
. red IP address display
. bytes in/out
. VNC over SSH
. time sync
. ad zapping
. ip accounting on 0.9.9 / 1.0
. ip accounting on 2.0
. status LEDs
. adding web users
. iptables config
. internal PPTP VPN
. RRDTool traffic graphs
. password reset
. proxy log analysis
. RRDTool memory graphs
. Squid config
. adding shell users
. Smoothwall links
 
 modem config
. Billion 7402L adsl router
. DSL-300G adsl modem
. DSL-300+ adsl modem
 
 site search
Custom Search
 
Ad Zapping with Squid

[This modification has been verified to work with Smoothwall GPL 1.0 and Smoothwall Express 2.0.]

This page will show you how to install and configure an ad zapping script to zap any advertisments on web pages.

Requirements:
You'll need:
  • A Smoothwall GPL 1.0 or Express 2.0 installation (obviously...), with the Squid web proxy turned on.
  • Ad Zap tarball (download it from the Ad Zap website).
  • An SCP client (such as WinSCP, or SSH Secure File Transfer Client, part of SSH Secure Shell) for copying files onto your Smoothwall box.
  • A way of getting a command-line prompt on your Smoothwall box (either by logging directly onto your Smoothwall box, using a SSH client such as PuTTY or SSH Secure Shell, or via the Smoothwall web interface).
Configuration:
Ensure you have SSH enabled on your Smoothwall (it's configured on the "remote access" page. This is required for copying files to your Smoothwall via SCP, and for logging into your Smoothwall with SSH.

Download the Ad Zap tarball, and SCP it into the /tmp directory on your Smoothwall box.

Open a SSH connection to your Smoothwall, and run the following commands to unzip the Ad Zap tarball (adjust the tarball name as required):

tar zxvf /tmp/adzap-20030103.tar.gz -C /usr/local

Edit /usr/local/adzap/scripts/wrapzap and change the zapper value to

zapper=/usr/local/adzap/scripts/squid_redirect

Edit /var/smoothwall/proxy/acl, and add the following line to the end of the file:

  redirect_program /usr/local/adzap/scripts/wrapzap

Now go to the proxy configuration page on your Smoothwall box, and click the "Save" button to re-write /var/smoothwall/proxy/squid.conf and make your changes take effect.

Customising Pattern Files:
You can customise the pattern files to add additional ad sites or to stop Ad Zap from zapping ads from certain sites.

To do so, create a new file in /usr/local/adzap/rc/ called pre_match.
In this file, add a line for each additional rule you want to ad to Ad Zap. Keep in mind that the file you're creating will be used prior to the main pattern list.

For example, if you didn't want to zap any ads from the overclockers.com.au website or Google ads, you would specify the following in your pattern file:

PASS http://*.overclockers.com.au/**
PASS http://*.googlesyndication.com/**

Edit /usr/local/adzap/scripts/wrapzap and tell it the location of your pattern file:

ZAP_PREMATCH=/usr/local/adzap/rc/pre_match

If you want to specify patterns which will be used after the main pattern list, create a file in /usr/local/adzap/rc/ and specify the filename in the ZAP_POSTMATCH setting in /usr/local/adzap/scripts/wrapzap.

To make your changes take effect, restart Squid by going to the proxy configuration page on your Smoothwall box, and clicking the "Save" button.

Refer to the Ad Zap page for more information on customising the pattern files.

Testing:
Clear your web browser cache, and start surfing. You should find most ads are now replaced with some this ad zapped images.


sample webpage, showing several zapped ads

Above is a screenshot of a webpage, showing how adzap replaces the text-based ads with a text string saying "This ad zapped", and how it replaces graphical ads with a new image.

Customising Placeholder Images:
The default placeholder image used for replacing ads is http://adzapper.sourceforge.net/zaps/ad.gif


default placeholder image

This image will be scaled to suit the size of the advertisment it's replacing.
Note that this image won't be downloaded from the adzapper website each time - it'll be cached locally after the first time (and it's only a tiny 143 bytes).

Instead of using images, you can replace advertisements with blank images.
To do so, edit /usr/local/adzap/scripts/wrapzap, and set the value of the ZAP_MODE parameter:

ZAP_MODE=CLEAR

Restart Squid through Smoothwall's web interface, clear your browser cache, and you should now see advertisments replaced with blank space.

You can also replace the images with custom versions.

The Ad Zap tarball includes sample images, located in /usr/local/adzap/zaps/.
To use these local images (or any custom replacements you create), create a symbolic link to that directory:

ln -s /usr/local/adzap/zaps /home/httpd/html

Edit /usr/local/adzap/scripts/wrapzap and specify the location of your zaps directory:

ZAP_BASE=http://172.16.0.1:81/zaps

Note: replace the IP address with your Smoothwall's green IP address.

Restart Squid through Smoothwall's web interface, clear your browser cache, and you should now see advertisments replaced with the local images.

References:
Ad Zapping with Squid

Happy Users:
I've heard positive feedback from numerous people who have implemented adzap on their Smoothwall boxes. I cannot take the credit for adzap - it was written by Cameron Simpson.

I saw adzap, loved it, implemented it on my Smoothwall, and decided to put this page together to make it easy for others to enjoy the benefits of adzap on Smoothwall.

A quote from one happy user on IRC:

<kaleidox> i have a company full of surfing engineers kissing my butt they are so happy about that little mod ;)



last updated 19 May 2005
 
.