Search squid archive

Re: redirecting squid

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

 



frevol nicolas wrote:

hi,

i am trying to use use squid with an external program.
So i did:
"redirect_program /home/mysession/rep/executable"

In my Perl executable, i take the argv[0] value.

But what kind ok value do i have to print out ?
for example my perl script is :
-------------------------
#!/usr/bin/perl -w
use strict;

$|=1;
while (<>) {
  my @X = split;
  my $url = $X[0];
  my $test = 0;   #just a test value for later
     if ($url =~ /^http:\/\/internal\.foo\.com/) {
	 $url =~ s/^http/https/;
	 $url =~ s/internal/secure/;
	 if($test==0){
		print "302:$url\n";
	 }else{
		print  "file:///home/template.html";
	 }
     }else{
	 if($test==0){
		print "http://fr.yahoo.com\n";;
	 }else {
		print  "file:///template.html";
	 }
     }
}
It looks like you've already hit the FAQ...

------------------------- the result is that i have the yahoo site on my screen
without pictures.
Do you understand what this Perl script is doing? If the requested URL matches http://internal.foo.com (with or without trailing characters), it will be rewritten to "https://secure.foo.com";. Otherwise, if the variable "test" is set to zero (as it is) EVERY request will be rewritten as "http://fr.yahoo.com";, (even requests for images referenced by that page).

and if i replace print "http://fr.yahoo.com\n";; by
print "file:///template.html";

it doesn't works

This is equivalent to setting the variable "test" to something other than zero and will cause Squid to request file:///template.html. That would be a pretty nasty security hole (letting someone access arbitrary files on the proxy server itself).

any ideas?
Find someone a bit more familiar with Perl, or get a good Perl book and re-read the FAQ section on redirectors. :o)

Chris

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

  Powered by Linux