[squid-users] Squid Redirection Scripting

Willsz.net willsznet at gmail.com
Mon Apr 10 08:26:39 UTC 2017


Hi, folks

Hi, I used Perl Scripting for 1 year couple ago. But this script doesn't 
work with new version Squid.

root:~# uname -smrm
FreeBSD 9.3-STABLE i386

root:~# squid -v
Squid Cache: Version 3.5.24
Service Name: squid
configure options:  '--prefix=/usr/local' 
'--includedir=/usr/local/include' '--bindir=/usr/local/sbin' 
'--libexecdir=/usr/local/libexec/squid' 
'--sysconfdir=/usr/local/etc/squid' '--with-default-user=squid' 
'--localstatedir=/var/cache/squid' '--libdir=/usr/local/lib' 
'--with-logdir=/var/log/squid' '--with-pidfile=/var/run/squid.pid' 
'--with-swapdir=/var/cache/squid' '--without-gnutls' 
'--enable-build-info' '--enable-loadable-modules' 
'--enable-removal-policies=lru,heap' '--disable-epoll' 
'--disable-linux-netfilter' '--disable-linux-tproxy' 
'--disable-translation' '--disable-arch-native' 
'--mandir=/usr/local/man' '--infodir=/usr/local/info' '--disable-wccp' 
'--disable-wccpv2' '--enable-ipfw-transparent' '--enable-ssl-crtd' 
'--with-openssl' '--with-large-files' '--disable-htcp' '--disable-eui' 
'--enable-cachemgr-hostname=ip.proxy-cache.willsz.net' 
'--disable-auth-negotiate' --enable-ltdl-convenience

Here's my script:

#!/usr/local/bin/perl

$|=1;

while (<>) {
chomp;
@X = split;
$url = $X[0];

     if ( $url =~ m{ ^https?://(?:
         ad[0-9]?        |
         ad[szvx]?[0-9]? |
         ads[0-9]?       |
         adsbox          |
         adserver        |
         adservices?     |
         adserving       |
         adv             |
         advertising     |
         banners?        |
         adserver)\.(.*) }x ) {
             print "http://somedomain.com/null.png\n";
     }

     else {
         print "$url\n";
     }
}

Anyone guide me to make it work?

Thank you.


More information about the squid-users mailing list