| feb2004.tar |
Listing 7 Perl redirector for Squid -- myredirector.pl
#!/usr/bin/perl
$|=1; #Flush any buffer asap.
#Read Standard input, one request at a time from squid.
while(<>) #Infinite loop. So running as a daemon..
{
#Read URL first (first argument)
$url=(split)[0];
#Modify URL(search and replace), (power of programming comes handy here)
$url =~ s/^http:\/\/www.mywebserver.xxx/http:\/\/www.realwebserver.xxx:8080/
#Print modified URL to stdout which will be picked up by squid.
print $url;
}
|