Re: [squid-users] adding a parameter to a URL / Problem in the url_redirect program

From: Shaine <gsm_linux_at_yahoo.co.uk>
Date: Sun, 6 Jul 2008 22:05:52 -0700 (PDT)

Dear Friends,

Thanks a lot for all the support so far. Little by little i have some
solutions. But my redirect programs behave very unusual way. Its a working
script. How would i say , when i pass argument via comand line , result was
as i expected. but when its in squid , it doesnt act how it supposed to
work.

All the web requests comes into the redirect program , its adding "VALUE-X"
value into the script. But here i am doing grep for "?" mark in to
requested url , if its matched doing another function squid itself. it was
success.

When a web request receives as follows ,
http://10.48.15.1:8080/main/main_view?id=7
that adding of the value wont happen.why is that ? why its not perform in
squid redirector program ? doi have to do any thing special in squid or in
the perl script ?

Following is my script.

#!/usr/bin/perl
# no buffered output, auto flush
use strict;
use warnings;

my ($temp, $array, @array, $param_1, $param_2, $param_3, $new_uri);

$|=1;
$temp = "";

while (<STDIN>){
  #@array = split(/ /);
  ($param_1, $param_2, $param_3) = split(/ /);
  #if (!($array[1] =~ m#VALUE-X#)) {
  if (!($param_2 =~ m#VALUE-X#)) {
    $temp = $param_2;
    if ($param_2 =~ m#\?#) {
      $temp .= "&VALUE-X=652224848";
    }else {
      $temp .= "?VALUE-X=652224848";
    }
    $new_uri = ($param_1 . " " . $temp . " " . $param_3);
    s#$param_2#$temp#;
    #print $new_uri;
    print;
  }else {
    print;
  }
}

============================================

Thank you
Shaine.

Marcus Kool wrote:
>
> Shaine,
>
> Because you use the 302: prefix the URL that you pass back from the
> redirector
> to Squid is sent back to the browser and because of the 302 the browser
> sends a new request to Squid and the new URL is the URL that the
> redirector sent
> in the first place. This URL is passed by Squid to the redirector and now
> you
> have an endless loop.
>
> solution:
> - do not use the 302: prefix, or
> - modify your perl code so that it checks for "orchard=66677722" in which
> case it must not
> rewrite the URL.
>
> -Marcus
>
>
> Shaine wrote:
>> Dear friedns,
>>
>> I am really fed up with url -redirecting program which i have used for
>> redirect specific url comes and validate by the url -rewriting program .
>> It
>> wasnt gave me any errors at initial steps.But now when i try to access
>> google or any url , its repating ( url * n ) ,
>>
>> eg:-
>> :http://www.yahoo.com/302:http://www.yahoo.com/302:http://www.yahoo.com/302:http://www.yahoo.com/302:http://www.yahoo.com/302:http://www.yahoo.com/302:http://www.yahoo.com
>>
>> following is my perl code ( url-redirecting program )
>>
>>
>> #!/usr/bin/perl
>> # no buffered output, auto flush
>> $|=1;
>> $temp = "";
>>
>> while (<STDIN>){
>> @array = split(/ /);
>> if (!(@array[1] =~ m#orchard#)) {
>> $temp = "302:" . @array[1];
>> if (@array[1] =~ m/\?/) {
>> $temp .= "&orchard=66677722";
>> }else {
>> $temp .= "?orchard=66677722";
>> }
>> s#@array[1]#$temp#;
>> print;
>> }else {
>> print;
>> }
>> }
>>
>>
>> Can somebody help me to solve my issue ? please help me. actually why it
>> is
>> happening like that .
>>
>> Many thanks
>> Shaine.
>>
>>
>>
>>
>> Sylvain Viart-2 wrote:
>>> Hi Shaine,
>>>
>>> Shaine a écrit :
>>>> I have a big problem with adding a parameter to a URL which passes via
>>>> squid
>>>> . For that i am going to use url_rewrite program. I had a big time with
>>>> squid url rewriting, but no success.
>>>>
>>>> Could you please tell me , to get in to my point what are the minimum
>>>> requirement to be satisfied ?
>>>>
>>> I haven't tested to rewrite the querystring part of the url, but it's
>>> available on the redirector (rewrite_program)
>>>
>>> Here's sample input for the rewrite_program
>>>
>>> 0
>>> http://www.somedomain.com/thumb/100/3/b/2/7/3b279a6eab3d0a983d9tre.somedomain.com/messenger/messPing.php
>>> 12.34.56.78/- - POST -
>>> 0
>>> http://subdom.somedomain.com/thumb/55/3/c/3/6/3c36046ed06c78b2b65627f660be6220.jpg
>>> 12.34.56.78/- - GET -
>>> 0
>>> http://www.somedomain.com/thumb/100/3/6/8/4/3684949288972604fafdb167ffc214d5.jpg
>>> 12.34.56.78/- - GET -
>>> 0
>>> http://www.somedomain.com/thumb/100/7/a/4/1/7a4113fd5fba8ec93fa6bf82a6c993be.jpg
>>> 12.34.56.78/- - GET -
>>> 0
>>> http://www..somedomain.com/thumb/100/4/3/d/f/43df2ca304f508557294d3a835a6fd29.jpg
>>> 12.34.56.78/- - GET -
>>>
>>> The digit in the first position is only present when
>>> url_rewrite_concurrency is used, see
>>>
>>> The thread : url_rewrite_concurrency singlethreaded redirector
>>> performance?
>>>
>>> http://www.mail-archive.com/squid-users@squid-cache.org/msg49897.html
>>>
>>>> url_rewrite_program
>>>> url_rewrite_children
>>>> url_rewrite_concurrency
>>>> url_rewrite_host_header on|off
>>>> url_rewrite_access allow|deny acl ...
>>>>
>>> I use :
>>> url_rewrite_program /etc/squid/redirector.pl
>>> url_rewrite_children 100
>>> url_rewrite_concurrency 50
>>> url_rewrite_host_header off
>>>
>>>
>>> which means :
>>>
>>> 100 process spawned (busy proxy)
>>> url_rewrite_concurrency 50, means squid can pass up to 50 URL to the
>>> program using a counter
>>>
>>> url_rewrite_host_header off, means that redirector rewrites the URL, but
>>> squid keep the original URL, useful in accelerator mode (surrogate), See
>>> the doc, to be sure.
>>>> how it should like , url rewrite program ? can somebody leave me a
>>>> simple
>>>> example ?
>>> Simple perl program :
>>>
>>> # no buffered output, auto flush
>>> $|=1;
>>>
>>> while(<STDIN>)
>>> {
>>> s#http://something/#http://somthingelse/#;
>>> print;
>>> }
>>>
>>>
>>> A bit fast answer, hope that helps.
>>>
>>>
>>> Regards,
>>> Sylvain.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>
>

-- 
View this message in context: http://www.nabble.com/adding-a-parameter-to-a-URL-tp17776816p18310093.html
Sent from the Squid - Users mailing list archive at Nabble.com.
Received on Mon Jul 07 2008 - 05:05:56 MDT

This archive was generated by hypermail 2.2.0 : Mon Jul 07 2008 - 12:00:04 MDT