Forum Discussion

Jim_Grundy_4363's avatar
Jim_Grundy_4363
Icon for Nimbostratus rankNimbostratus
Aug 15, 2009

append to a URI string

I don't know TCL very well, but I have been asked to write an iRule for internet only traffic. The rule must append to the end of the URI for internet traffic only. Internal access should not have this appended.

 

 

Any help would be appreciated.
  • Hi Jim

    I am going to make an assumption that internal address uses non-public private blocks. Thus, the logic will be if you are a not a private block then append the traffic.

     
     when HTTP_REQUEST {  
        if { !([IP::addr [IP::client_addr] equals 10.10.0.0/255.255.0.0]) } { 
          HTTP::uri /appenduri[HTTP::uri] 
        } 
     } 
     

    Or you can add logic where it checks to see if you are not a private block or haven't already appended the traffic

     
     when HTTP_REQUEST {  
        if { !([IP::addr [IP::client_addr] equals 10.10.0.0/255.255.0.0]) and !(HTTP::uri "/appendeduri" } { 
          HTTP::uri /appenduri[HTTP::uri] 
        } 
     } 
     

    Hope this helps

    CB

  • CB,

     

     

    Thanks for the quick response, I'll let you know how it works out.

     

     

    Jim
  • This sort of works, but not exactly. I think I need to redirect the browser to get it work with the variable.

     

     

    This is what I have so far.

     

     

    when HTTP_REQUEST {

     

     

    if { !([IP::addr [IP::client_addr] equals 10.0.0.0/255.0.0.0]) and !([IP::addr [IP::client_addr] equals 172.16.0.0/255.240.0.0]) } {

     

     

    HTTP::uri /[HTTP::uri]"&ra=0"

     

     

    set LogString "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri]"

     

    log local0. "============================================="

     

    log local0. "$LogString (request)"

     

    foreach aHeader [HTTP::header names] {

     

    log local0. "$aHeader: [HTTP::header value $aHeader]"

     

    }

     

    log local0. "============================================="

     

    }

     

    else {

     

    HTTP::uri /[HTTP::uri]

     

    }

     

    }
  • According to the server logs it is appending the &ra=0 to the end of the string, but the that is supposed to suppress attachments from Lotus Notes. It only seems to work if the &ra=0 comes from the users browser. If they manually add it to the end of the string it does suppress, if the iRule adds it doesn't. So I wanted to try a redirect with the append. I also don't see it appended in the logs either.