<div dir="ltr"><div><div><div><div><div>Hi, <br><br></div>We have a squid reverse configuration, and we need to change backend webserver with a new webserver with new IP and port (80 --> 8000) .<br><br></div>Old squid configuration used url_rewrite_program. I 'not familar with this configuration.<br></div><div>With port changing on new web server ( 80 --> 8000) , i find that i had to add new production web on url_rerite_program.<br></div><div><br></div>I tried to change program , but i met a issue.<br><br></div><div>on part 1 --> current rewrite program configuration running today and correctly for testurl --> running fine <br></div><div>on part 2 --> configuration with change for testurl and productionurl -> OK for productionurl and KO for testurl<br></div><div><br></div><div>An idea if something is wrong on change ? <br></div><div><br></div>Part 1) old configuration : <br><br>#!/usr/bin/perl<br><br>$INTERNALIP="15.40.40.40";<br>$PRODUCTIONURL="<a href="http://add.ptr.lu">add.ptr.lu</a>"; <br>$TESTURL="<a href="http://test.add.ptr.lu">test.add.ptr.lu</a>"; <br>$TESTPORT="8001";<br><br># turn off write buffering <br>$| = 1;<br>while (<>) { <br><br> # get the URL from the request <br> chomp($url = $_);<br><br> if ($url =~ m/($INTERNALIP|$TESTURL):$TESTPORT/)<br> {<br> # fix up the cname and port<br> $url =~ s^:$TESTPORT^^; <br> $url =~ s^$INTERNALIP^$TESTURL^; <br><br> # fix the protocol <br> $url =~ s^https://^http://^; <br> }<br> else<br> {<br> # fix up the name <br> $url =~ s^$INTERNALIP^$PRODUCTIONURL^; <br><br> # fix the protocol <br> $url =~ s^http://^https://^; <br> }<br><br> # return the fixed URL to squid <br> print "$url\n"; <br>}<br><br><br></div>Part 2) configuration with changes <br><br>#!/usr/bin/perl
<br> <br>$INTERNALIP="15.40.40.40";
<br>$PRODUCTIONURL="<a href="http://add.ptr.lu">add.ptr.lu</a>";
<br>$TESTURL="<a href="http://test.add.ptr.lu">test.add.ptr.lu</a>";
<br>$TESTPORT="8001";
<br>$PRODPORT="8000";
<br> <br># turn off write buffering
<br>$| = 1;
<br>while (<>) {
<br> <br> # get the URL from the request
<br> chomp($url = $_);
<br> <br> if ($url =~ m/($INTERNALIP|$TESTURL):$TESTPORT/)
<br> {
<br> # fix up the cname and port
<br> $url =~ s^:$TESTPORT^^;
<br> $url =~ s^$INTERNALIP^$TESTURL^;
<br> <br> # fix the protocol
<br> $url =~ s^https://^http://^;
<br> }
<br> <br>elsif ($url =~ m/($INTERNALIP|$PRODUCTIONURL):$PRODPORT/)
<br> {
<br> # fix up the cname and port
<br> $url =~ s^:$PRODPORT^^;
<br> $url =~ s^$INTERNALIP^$PRODURL^;
<br> <br> # fix the protocol
<br> $url =~ s^https://^http://^;
<br> }
<br> <br> else
<br> {
<br> # fix up the name
<br> $url =~ s^$INTERNALIP^$PRODUCTIONURL^;
<br> <br> # fix the protocol
<br> $url =~ s^http://^https://^;
<br> }
<br> <br> # return the fixed URL to squid
<br> print "$url\n";
<br>}<br><br><br><br></div>