> i am looking for a proxy which can "bounce" the request, which is not a 
> classic proxy.
> I want it works in this way.
> e.g. a proxy is running a 
> and when i want to open http://www.yahoo.com, i just need call 
> the proxy can pickup the the host "http://www.yahoo.com"; from the URI, and 
> retrieve the info for me‚Äč, 
> so it need to get the new $host from $location, and remove the $host from the 
> $location before proxy pass it.
> it is doable via squid?

Yes it is doable (but unusual).  First you need to tell Squid which requests 
should be rewritten, then send them to a rewrite program to be transformed.  
Identify the domains like this:

acl rewrite-domains dstdomain .yahoo.com .google.com etc)

Then set up a URL rewriting program, and only allow it to process requests 
matching the rewrite-domains ACL, like this:

url_rewrite_program /tmp/rewrite-program.pl
url_rewrite_extras "%>ru"
url_rewrite_access allow rewrite-domains
url_rewrite_access deny all

The program itself can be anything.  A very simple example in Perl might look 
like this:

use strict;
$| = 1;

# Enter loop
while (my $thisline = <>) {
        my @parts = split(/\s+/, $thisline);
        my $url = $parts[0];
        $url =~ s/http:\/\/(.*)/http:\/\/\/$1/g;
        print "OK rewrite-url=\"$url\"\n";

If you input http://www.yahoo.com/page.html, this will be transformed to  The helper just needs to print 
that out prepended by "OK rewrite-url=xxx".  More info at 

Of course, you will need something listening on (Apache, nginx, 
whatever) that can deal with those rewritten requests.  That is an unusual way 
of getting requests to though, because you are effectively putting 
the hostname component into the URL then sending it to a web service and 
expecting it to deal with that.

Another note.  If you have a cache_peer defined, you might need some config to 
force rewritten requests to be sent to and not your cache peer.  In 
that case this should do the trick:

acl rewrite-host dst
always_direct allow rewrite-host



squid-users mailing list

Reply via email to