Yes, I've read the mail but I think that it is better to post it here... ;-)
The main problem is that if I rewrite the $url (localhost [::1], or
[5001::52] [3001::52] that are the addresses of the interfaces) it doesn't
work. If I rewrite $url with "302:" code in front it works... but the
behavior of the system is completely different.
Replying to your requests, I'm working on 4 virtual machine called origin,
core, mobile1, mobile2. In the origin and mobile I have apache servers
running... those are my caches!!! When I write localhost, I want to redirect
to the apache link

example:
I receive GET for http://[6001::101]/Big/big1.avi and I want to rewrite it
like http://[5001::52]/Big/big1.avi, that is the link to the apache in the
same machine where Squid is installed. This is not working. But if I
redirect to another machine http://[4001::52]/Big/big1.aviwith apache it
works.

OK?

*[rewriter_code]*
#!/usr/bin/perl

use warnings;
use strict;
use Fcntl ':flock';

require '/home/alberto/NodeConfig.pm';                            #
dir/.../NodeConfig.pm
my $dirDB = ($NodeConfig::dir_DB);                                #
directory local database
my $db_name = ($NodeConfig::name_DB);                             # name of
local database
my $node_address = ($NodeConfig::node_address);                   # MAR's
address
my $DM_address = ($NodeConfig::DM_address);                       # DM's
address
my $dir_apache = ($NodeConfig::dir_Apache);                       #
directory of contents (Apache server)
my $dir_DM = ($NodeConfig::dir_DM);                               #
directory where there is the DM_req.pl in DM
my $rootpwd = ($NodeConfig::root_pwd);                            # password
for root access (to send the request to DM)

$|=1;

#-------------------------------------------------------------------------------------------------------------
#------------------------ PARAMETERS (modifying only ip address oCDN)
----------------------------------------

while (<>) {

                          my @params_http = split;                             
# parameters of http request
           my $url = $params_http[0];                           # url of
http request
           my $ip_client = $params_http[1];             # ip client oh http
request

                          my $absTime = time();                                 
       
# absolute time in seconds

                          my $db_name = ($NodeConfig::name_DB);
                          my $node_address = ($NodeConfig::node_address);
                          my @copie;

#----------------------------- REWRITE URL SQUID FUNCTION
----------------------------------------------------
# Check if there is the content inside he cache:
                      # if YES --> Go directly to MAR's cache
                      # if NO --> Forward the request to DM and wait the
best cache or Origin path


           open(LIST1, "< $dirDB"."$db_name"); # open local database for
READ
           flock ( LIST1, LOCK_SH );
           my @copieS=<LIST1>;
           flock ( LIST, LOCK_UN );
           close(LIST1);
           my $c;
           for $ind(0..$#copieS) {
                      my @values = split(';', $copieS[$ind]);
                      my $original =  $values[0];
                      my $copy = $values[1];
                      my $iT1 = $values[2];

                      # seeking in the datbase if the content is in the
cache
                      if (($url eq $original)and($iT1 eq "Y")) {
                                                                                
       
my @val1 = split('/', $url);
                                 if (-e
"$dir_apache"."$val1[3]"."/"."$val1[4]") {
                                                                                
       
my $newURL = "$val1[0]//$node_address/$val1[3]/$val1[4]";

                                                                print 
"$newURL\n";
                                                                #print 
"302:"."$newURL\n";
                                                                exit;
                                 }
                      }
                          }
                        # request to DM for best position of content (Origin or 
others MARs)
                        my $req = 
request($DM_address,$dir_DM,$url,$node_address);

                        print "$req\n";
}


#--------------------------------------- END rewriteurl.pl
---------------------------------------------------


#------------------------------------ Soubroutine to Forward the request to
DM -------------------------------

# subroutine to send the request for best position to DM (ssh call)
sub request {

           my $DM_address = $_[0];
           my $dir_DM = $_[1];
           my $url = $_[2];
           my $node_address = $_[3];


           my $length = length($DM_address);
           my $DM_addressSSH = substr($DM_address,1,$length-2);
           my $req_DM = "sshpass -p '$rootpwd' ssh -o
StrictHostKeyChecking=no root@"."$DM_addressSSH"." \'cd $dir_DM && ".'perl
'."$dir_DM".'DM_req.pl'." $url $node_address\'";
           $req_DM = `$req_DM`;

           return $req_DM;






--
View this message in context: 
http://squid-web-proxy-cache.1019090.n4.nabble.com/Squid-3-2-2-localhost-tp4657098p4657103.html
Sent from the Squid - Users mailing list archive at Nabble.com.

Reply via email to