httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Kraemer <>
Subject [TIP]: How to use an Apache Proxy to filter Advertisements
Date Fri, 18 Apr 1997 10:00:01 GMT

Here's a short note about a "feature" which can easily be realized using
one of the latest apaches: the optional filtering of unwanted
ads/commercials/promotions/sponsor banners etc. In place of the
requested advertisement gif, a small "NoAds.gif" image is delivered
(which is available locally on the server).

On our proxy server, we offer a second port which delivers the filtered
services, while the primary port works transparently:

    Port   80
    # Primary server Port 80
    Listen 80
    # Anti-SPAM Port 81
    Listen 81

We configure our server as proxy and enable the rewriting module (needs
mod_rewrite and mod_proxy defined in Configuration, and mod_proxy must
be defined _prior_to_ the definition of mod_rewrite!!!):

<IfModule mod_proxy.c>
  ProxyRequests      On
  ProxyRemote        *

This virtual host on the second port is now configured to filter ads.
A <VirtualHost> directive is used for this purpose, in order not to
disturb services on the primary port. The rules can be explained as

    1) When the browser sent a "Pragma: No-Cache" header (Reload pressed),
       proceed normally and serve the request. Otherwise:

    2) if the request contains a subdirectory called /sponsor/, /ads/, /
       promotion/ and the like, (or /werbung/ for a german server),

    3) serve the NoAds.gif instead.

The rules could of course be refined to check whether the request really
tried to load a *.jpeg, *.gif or *.png graphics file. But the result is
already astonishingly successful.

  ##### Anti-SPAM on port 81. Filter out typical commercials, unless [Reload] pressed
  RewriteEngine On
  #RewriteLog   logs/rewrite_log
  #RewriteLogLevel 2
  RewriteCond  %{HTTP:Pragma}  !^no-cache                               [NC]
  RewriteCond  %{REQUEST_URI}  ^http://[^/]*.*/[Pp]romotions/           [OR]
  RewriteCond  %{REQUEST_URI}  ^http://[^/]*.*/[Aa]d[vs]/               [OR]
  RewriteCond  %{REQUEST_URI}  ^http://[^/]*.*/[Ss]ponsors*/            [OR]
  RewriteCond  %{REQUEST_URI}  ^http://[a-zA-Z0-9.]*.de/[Ww]erbung/
  RewriteRule  ^.*$            /var/WWW/Web/images/NoAds.gif


View raw message