[squid-users] Change url_rewrite_program problem

Hicham Berni bernih75 at gmail.com
Tue Aug 18 13:43:02 UTC 2015


Hi,

We have a squid reverse configuration, and we need to change  backend
webserver  with a new webserver with new IP and port (80 --> 8000) .

Old squid configuration used url_rewrite_program. I 'not familar with this
configuration.
With port changing on new web server ( 80 --> 8000) , i find that i had to
add new production web on url_rerite_program.

I tried to change program , but i met a issue.

on part 1 --> current rewrite program configuration  running today and
correctly  for testurl --> running fine
on part 2 --> configuration with change  for testurl and productionurl ->
OK for productionurl and KO for testurl

An idea if something is wrong on change ?

Part 1)  old configuration :

#!/usr/bin/perl

$INTERNALIP="15.40.40.40";
$PRODUCTIONURL="add.ptr.lu";
$TESTURL="test.add.ptr.lu";
$TESTPORT="8001";

# turn off write buffering
$| = 1;
while (<>) {

  # get the URL from the request
  chomp($url = $_);

  if ($url =~ m/($INTERNALIP|$TESTURL):$TESTPORT/)
  {
    # fix up the cname and port
    $url =~ s^:$TESTPORT^^;
    $url =~ s^$INTERNALIP^$TESTURL^;

    # fix the protocol
    $url =~ s^https://^http://^;
  }
  else
  {
    # fix up the name
    $url =~ s^$INTERNALIP^$PRODUCTIONURL^;

    # fix the protocol
    $url =~ s^http://^https://^;
  }

  # return the fixed URL to squid
  print "$url\n";
}


Part 2) configuration with changes

#!/usr/bin/perl

$INTERNALIP="15.40.40.40";
$PRODUCTIONURL="add.ptr.lu";
$TESTURL="test.add.ptr.lu";
$TESTPORT="8001";
$PRODPORT="8000";

# turn off write buffering
$| = 1;
while (<>) {

  # get the URL from the request
  chomp($url = $_);

  if ($url =~ m/($INTERNALIP|$TESTURL):$TESTPORT/)
  {
    # fix up the cname and port
    $url =~ s^:$TESTPORT^^;
    $url =~ s^$INTERNALIP^$TESTURL^;

    # fix the protocol
    $url =~ s^https://^http://^;
  }

elsif ($url =~ m/($INTERNALIP|$PRODUCTIONURL):$PRODPORT/)
  {
    # fix up the cname and port
    $url =~ s^:$PRODPORT^^;
    $url =~ s^$INTERNALIP^$PRODURL^;

    # fix the protocol
    $url =~ s^https://^http://^;
  }

  else
  {
    # fix up the name
    $url =~ s^$INTERNALIP^$PRODUCTIONURL^;

    # fix the protocol
    $url =~ s^http://^https://^;
  }

  # return the fixed URL to squid
  print "$url\n";
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squid-cache.org/pipermail/squid-users/attachments/20150818/20b48f81/attachment.html>


More information about the squid-users mailing list