Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Adzapping with Squid package (2.6.21_xx)

    Scheduled Pinned Locked Moved pfSense Packages
    2 Posts 2 Posters 8.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      Tikimotel
      last edited by

      How to install adzapper in combination with pfSense 1.2.1 (RC1-RC2)
      usefull sites:
      http://www.freshports.org/www/adzap/
      http://adzapper.sourceforge.net/
      http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
      http://winscp.net/eng/index.php

      Before we continue:
      You must have basic knowledge of how to login via ssh (using "putty" for example).
      You have installed winSCP and are able to upload and download files from your pfSense router.
      You only have the squid package installed. (I have no experience with using multiple squid related packages at the same time, like squidguard or lightsquid.)
      Squid is running for you and you don't have any troubles with it.
      extra: your pfSense webconfigurator page is available on tcp-port 80 (default) (http service on tcp port 80)

      Get the adzapper package:
      login to your pfSense router using putty.
      run :

      pkg_add -r adzap
      

      adzap will download from freshports and give you some hints on installing it further.
      ?only works with pfsense 1.2.1, because of freebsd version used, files can be uploaded and unpacked via winSCP too, just download original from adzapper site?
      Installing and Editing the basic entries of "adzap.conf":
      adzap.conf needs to be in this location.

      /usr/local/etc/
      

      adzap.conf (already modified for pfSense install)

      
      # example adzap configuration file
      # copy this file over to ${PREFIX}/etc/adzap.conf,
      # then modify this to match your install
      
      ZAP_MODE=CLEAR				# or "CLEAR"
      ZAP_BASE=http://192.168.0.1/zaps	# a local web server will be better (192.168.0.1 is my pfSensebox)
      ZAP_BASE_SSL=https://adzapper.sourceforge.net/zaps # this can probably be ignored
      ZAP_PREMATCH=				# pathname of extra pattern file
      					# for patterns to preempt the stock
      					# zapper
      ZAP_POSTMATCH=/usr/local/libexec/zapper_block				# pathname of extra pattern file (my extra usefull zaps)
      					# for patterns in addition to the
      					# stock zapper; this is the one to
      					# which you should add new ads
      
      STUBURL_AD=$ZAP_BASE/ad.gif
      STUBURL_ADSSL=$ZAP_BASE_SSL/ad.gif
      STUBURL_ADBG=$ZAP_BASE/adbg.gif
      STUBURL_ADJS=$ZAP_BASE/no-op.js
      STUBURL_ADHTML=$ZAP_BASE/no-op.html
      STUBURL_ADMP3=$ZAP_BASE/ad.mp3
      STUBURL_ADPOPUP=$ZAP_BASE/closepopup.html
      STUBURL_ADSWF=$ZAP_BASE/ad.swf
      STUBURL_COUNTER=$ZAP_BASE/counter.gif
      STUBURL_COUNTERJS=$ZAP_BASE/no-op-counter.js
      STUBURL_COUNTERHTML=$ZAP_BASE/no-op-counter.html
      STUBURL_WEBBUG=$ZAP_BASE/webbug.gif
      STUBURL_WEBBUGJS=$ZAP_BASE/webbug.js
      STUBURL_WEBBUGHTML=$ZAP_BASE/webbug.html
      
      STUBURL_PRINT=				# off by default, set to 1
      
      

      executable : chmod 0755 (rwxr-xr-x), files
      go to```
      /usr/local/libexec/

      files that need to be here:
      "adzap" (basically the same as the adzap.conf, it is the redirector)
      "squid_redirect" (basic rule set and script, can be downloaded separately, pkg_add should have installed a copy here already, update this via [http://adzapper.sourceforge.net/](http://adzapper.sourceforge.net/) when newer versions are available. )
      "zapper_block" (created file, chmodded to allow execute)
      
      _zapper_block (extra) content:_
      

      ADJS http://.vibrantmedia.com/intellitxt/front.asp?**
      ADJS http://
      .de.intellitxt.com/intellitxt/front.asp?**
      ADJS http://.us.intellitxt.com/intellitxt/front.asp?**
      ADJS http://
      .uk.intellitxt.com/intellitxt/front.asp?**
      ADJS http://.intellitxt.com/intellitxt/front.asp?**
      ADJS http://
      .smarttargetting.com/system/ExternalAdServeRedirect.asp?**
      ADJS http://.smarttargetting.net/system/ExternalAdServeRedirect.asp?**
      ADJS http://kona.kontera.com/javascript/lib/KonaLibInline.js
      ADJS http://pagead2.googlesyndication.com/pagead/show_ads.js
      ADJS http://
      .snap.com/**
      ADJS http://*.tomshardware.com/$script**

      _adzap (executable) (already modified for pfSense install)_
      

      #!/bin/sh

      Wrapper to set environment variables then exec the real zapper.

      The reasons for this are twofold:

      - for some reason squid doesn't preserve the original environment

      when you do a restart (or SIGHUP)

      - to avoid having to hack the squid startup script (if you have

      a presupplied one, such as ships with some linux distributions)

      Install in the same directory you put the zapper (just for convenience) and

      hack the pathnames below to suit.

      Note that you can skip this script and run the zapper with no environment

      settings at all and it will work fine; the variables are all set here merely

      for completeness so that customisation is easy for you.

      - Cameron Simpson cs@zip.com.au21apr2000

      modify this to match your install

      zapper=/usr/local/libexec/squid_redirect

      ZAP_MODE=CLEAR # or blank
      ZAP_BASE=http://192.168.0.1/zaps # a local web server will be better
      ZAP_BASE_SSL=https://adzapper.sourceforge.net/zaps # this can probably be ignored

      ZAP_PREMATCH= # pathname of extra pattern file
      # for patterns to preempt the stock
      # zapper
      ZAP_POSTMATCH=/usr/local/libexec/zapper_block # pathname of extra pattern file
      # for patterns in addition to the
      # stock zapper; this is the one to
      # which you should add new ads
      ZAP_MATCH= # pathname of extra pattern file
      # for patterns to use instead of the
      # inbuilt pattern list
      ZAP_NO_CHANGE= # set to "NULL" is your proxy is Apache2 instead of Squid

      STUBURL_AD=$ZAP_BASE/ad.gif
      STUBURL_ADSSL=$ZAP_BASE_SSL/ad.gif
      STUBURL_ADBG=$ZAP_BASE/adbg.gif
      STUBURL_ADJS=$ZAP_BASE/no-op.js
      STUBURL_ADJSTEXT=
      STUBURL_ADHTML=$ZAP_BASE/no-op.html
      STUBURL_ADHTMLTEXT=
      STUBURL_ADMP3=$ZAP_BASE/ad.mp3
      STUBURL_ADPOPUP=$ZAP_BASE/closepopup.html
      STUBURL_ADSWF=$ZAP_BASE/ad.swf
      STUBURL_COUNTER=$ZAP_BASE/counter.gif
      STUBURL_COUNTERJS=$ZAP_BASE/no-op-counter.js
      STUBURL_COUNTERHTML=$ZAP_BASE/no-op-counter.html
      STUBURL_WEBBUG=$ZAP_BASE/webbug.gif
      STUBURL_WEBBUGJS=$ZAP_BASE/webbug.js
      STUBURL_WEBBUGHTML=$ZAP_BASE/webbug.html

      STUBURL_PRINT= # off by default, set to 1

      . /usr/local/etc/adzap.conf

      export ZAP_MODE ZAP_BASE ZAP_BASE_SSL ZAP_PREMATCH ZAP_POSTMATCH ZAP_MATCH ZAP_NO_CHANGE
      export STUBURL_AD STUBURL_ADSSL STUBURL_ADJS STUBURL_ADHTML STUBURL_ADMP3
      STUBURL_ADPOPUP STUBURL_ADSWF STUBURL_COUNTER STUBURL_COUNTERJS
      STUBURL_COUNTERHTML STUBURL_WEBBUG STUBURL_WEBBUGJS STUBURL_WEBBUGHTML
      STUBURL_PRINT STUBURL_ADHTMLTEXT STUBURL_ADJSTEXT

      Here, having arranged the environment, we exec the real zapper.

      If you're chaining redirectors then comment out the direct exec below and

      uncomment (and adjust) the exec of zapchain which takes care of running

      multiple redirections.

      exec "$zapper"

      exec /path/to/zapchain "$zapper" /path/to/another/eg/squirm/cs@zip.com.au

      **Prepare ad replacement files (blank/empty) on a local server (your own pfSense router)**
      goto :```
      /usr/local/share/examples/adzap/zaps/
      

      copy it's contents to a new folder here:```
      /usr/local/www/zaps/

      folder rights : chmod 0755 (rwxr-xr-x), file rights : chmod 0644 (rw-r–r--)
      
      **Now tell squid to use adzapper as a redirector:**
      go to the "services" –> "proxy server" web page on your pfSense router.
      add the lines to the "Custom Options" box down below (press save).
      

      redirect_program /usr/local/libexec/adzap;

      **check if adzapper is up and running:**
      

      ps ax | grep squid

      1812  ??  Is     0:00.00 /usr/local/sbin/squid -D
      1815  ??  S      0:11.66 (squid) -D (squid)
      2984  ??  Is     0:07.42 /usr/bin/perl -w /usr/local/libexec/squid_redirect (p
      2985  ??  Is     0:03.27 /usr/bin/perl -w /usr/local/libexec/squid_redirect (p
      2986  ??  Is     0:02.35 /usr/bin/perl -w /usr/local/libexec/squid_redirect (p
      2987  ??  Is     0:01.99 /usr/bin/perl -w /usr/local/libexec/squid_redirect (p
      2988  ??  Is     0:01.78 /usr/bin/perl -w /usr/local/libexec/squid_redirect (p
      2993  ??  Is     0:01.61 /usr/bin/perl -w /usr/local/libexec/squid_redirect (p
      2994  ??  Is     0:01.53 /usr/bin/perl -w /usr/local/libexec/squid_redirect (p
      2995  ??  Is     0:01.51 /usr/bin/perl -w /usr/local/libexec/squid_redirect (p
      2996  ??  Is     0:01.50 /usr/bin/perl -w /usr/local/libexec/squid_redirect (p
      3010  ??  Is     0:01.50 /usr/bin/perl -w /usr/local/libexec/squid_redirect (p
      14200  p0  R+     0:00.00 grep squid

      **TIP! Any file change, will require a re-check / re-configure with squid (save the proxy server page in browser) in order for the changes to take effect.**
      
      Hope it will work for you and make your internet experience more ad free and more enjoyable.
      It's not hard to get it installed and running, just retrace your steps.
      1 Reply Last reply Reply Quote 0
      • belleraB
        bellera
        last edited by

        Hello!

        I integrated squidGuard + VideoCache using zapchain script from AddZapper.

        My installation uses a separate FreeBSD box to my pfSense and I documented it at http://www.bellera.cat/josep/videocache

        Perhaps it could help (for caching youtube videos and similar) if somebody want to try it in a pfSense box.

        Regards,

        Josep Pujadas

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.