Re: [squid-users] url_rewriter problem

From: Chris Robertson <crobertson_at_gci.net>
Date: Fri, 20 Feb 2009 12:39:32 -0900

Carlos Mart�nez-Troncoso C. wrote:
> Hello Squid gurus.
>
> I am having this problem with url_rewriter:
>
> Squid Version:
>
> Squid Cache: Version 3.0.STABLE7
> configure options: '--build=i686-redhat-linux-gnu'
> '--host=i686-redhat-linux-gnu' '--target=i386-redhat-linux-gnu'
> '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr'
> '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc'
> '--includedir=/usr/include' '--libdir=/usr/lib'
> '--libexecdir=/usr/libexec' '--sharedstatedir=/usr/com'
> '--mandir=/usr/share/man' '--infodir=/usr/share/info'
> '--exec_prefix=/usr' '--bindir=/usr/sbin'
> '--libexecdir=/usr/lib/squid' '--localstatedir=/var'
> '--datadir=/usr/share' '--sysconfdir=/etc/squid'
> '--disable-dependency-tracking' '--enable-arp-acl'
> '--enable-auth=basic,digest,ntlm,negotiate'
> '--enable-basic-auth-helpers=LDAP,MSNT,NCSA,PAM,SMB,YP,getpwnam,multi-domain-NTLM,SASL'
> '--enable-negotiate-auth-helpers=squid_kerb_auth'
> '--enable-cache-digests' '--enable-cachemgr-hostname=localhost'
> '--enable-delay-pools' '--enable-digest-auth-helpers=password'
> '--enable-epoll'
> '--enable-external-acl-helpers=ip_user,ldap_group,unix_group,wbinfo_group'
> '--enable-icap-client' '--enable-ident-lookups' '--with-large-files'
> '--enable-linux-netfilter' '--enable-ntlm-auth-helpers=SMB,fakeauth'
> '--enable-referer-log' '--enable-removal-policies=heap,lru'
> '--enable-snmp' '--enable-ssl'
> '--enable-storeio=aufs,coss,diskd,null,ufs' '--enable-useragent-log'
> '--enable-wccpv2' '--with-aio' '--with-default-user=squid'
> '--with-filedescriptors=65536' '--with-dl'
> '--with-openssl=/usr/kerberos' '--with-pthreads'
> 'build_alias=i686-redhat-linux-gnu' 'host_alias=i686-redhat-linux-gnu'
> 'target_alias=i386-redhat-linux-gnu' 'CFLAGS=-fPIE -Os -g -pipe
> -fsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
> -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386
> -mtune=generic -fasynchronous-unwind-tables' 'LDFLAGS=-pie'
> 'CXXFLAGS=-fPIE -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
> -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32
> -march=i386 -mtune=generic -fasynchronous-unwind-tables' 'FFLAGS=-O2
> -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
> --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic
> -fasynchronous-unwind-tables'
>
> We want to rewrite all URLS going to ezproxy.uninorte.edu.co, for
> example
> http://ezproxy.uninorte.edu.co:2048/login?url=http://search.eb.com/
> must be rewritten to http://search.eb.com/ (the URL always starts with
> http://ezproxy.uninorte.edu.co:2048/login?url=)
>
> We wrote this script in PERL:
>
> #!/usr/bin/perl -wl
> $|=1;
> while (<>)
> {
> @X = split (/=/);
> $url = $X[0];
> if ($url =~ /^http:\/\/ezproxy\.uninorte\.edu\.co:2048/) {
> $url = $X[1];
> print "$url\n";

You don't need to return an end of line character in the print
statement. In fact, doing so will fill your cache log with...

helperHandleRead: unexpected reply on channel 0 from url_rewriter #1 ''

...messages.

> }else {
> print "$url\n"; }
> }
>
> In squid.conf I configured (I tried with url_regex only, then with
> dstdomain only, this the "final version"):
>
> acl url_ezproxy url_regex -i ezproxy.uninorte.edu.co*
> acl rw dstdomain ezproxy.uninorte.edu.co
> url_rewrite_access allow url_ezproxy
> url_rewrite_access allow rw
> url_rewrite_access deny all
> url_rewrite_children 50
> url_rewrite_program /etc/squid/redirector/ezproxy.pl
>
> When i test to access a URL starting with exproxy... (the browser is
> configured to pass all by a proxy) the URL is not rewritten. I tested
> the PERL script in a command line and it works, the permissions are
> 770, owner squid.squid.
>
> I looked in the logs but the URL writer is not working, I suspect my
> url_rewrite_access is bad, but I looked in the docs and it seems it�s ok.

What does your cache log say when you reload or restart Squid?

You might precede the dstdomain url with a period (e.g. "acl rw
dstdomain .ezproxy.uninorte.edu.co"), to match
www.ezproxy.uninorte.edu.co (or maybe you don't want to).

> What can I do? What is the error?

The script given works for me (with the unexpected reply error message
mentioned earlier).

> Thanks in advance.

Chris
Received on Fri Feb 20 2009 - 21:39:39 MST

This archive was generated by hypermail 2.2.0 : Sat Feb 21 2009 - 12:00:02 MST