Search squid archive

Re: Squid Redirection Scripting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/04/2017 8:26 p.m., Willsz.net wrote:
> 
> Hi, folks
> 
> Hi, I used Perl Scripting for 1 year couple ago. But this script doesn't
> work with new version Squid.

Please explain "doesn't work".
Does it make all your traffic divert to cat pictures now?
  something else?


What was your previous version of Squid.
 2.7?  3.5.23?  something else?


> 
> root:~# uname -smrm
> FreeBSD 9.3-STABLE i386
> 
> root:~# squid -v
> Squid Cache: Version 3.5.24
> Service Name: squid
...
>  '--with-openssl'

NP: Since this is a self-build with OpenSSL I recommend upgrade to
3.5.25. For other reasons that your current problem, but it may solve both.


> 
> 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 ) {

Does that regex actually work?

1) I've never known URLs to contain long series of whitespaces like that.

2) ad[szvx]?[0-9]? matches the same things as ad[0-9]? and ads[0-9]? and
adv.



>             print "http://somedomain.com/null.png\n";;
>     }
> 
>     else {
>         print "$url\n";
>     }
> }
> 
> Anyone guide me to make it work?
> 

>From the overall structure and output I am guessing that this is a Squid
URL re-writer or Store-ID helper.


IMO you should replace this simple helper with ACLs. Like so:

squid.conf:
 acl adverts_domain dtsdom_regex "/etc/squid/adverts_domain.regex"
 deny_info 302:http://somedomain.com/null.png adverts_domain
 http_access deny adverts_domain

/etc/squid/adverts_domain.regex:
   ad[szvx]?[0-9]?\.
   adsbox\.
   adserv(er|ing|ices?)\.
   adv(ertising)?\.
   banners?\.


Amos

_______________________________________________
squid-users mailing list
squid-users@xxxxxxxxxxxxxxxxxxxxx
http://lists.squid-cache.org/listinfo/squid-users




[Index of Archives]     [Linux Audio Users]     [Samba]     [Big List of Linux Books]     [Linux USB]     [Yosemite News]

  Powered by Linux