Forum Discussion

Robert_LaGrasse's avatar
Robert_LaGrasse
Icon for Nimbostratus rankNimbostratus
Jul 14, 2006

Appending address to uri

Stuck this in the wrong forum before...

 

 

Probably a very simple task for you iRule gurus out there, not so simple for my first iRule. Here's what I'm trying to accomplish... when the client request comes in to the login.aspx page on my host, I want to append an & or ? and his IP address to the uri. Here's what I've built, which is not working.

 

 

when HTTP_REQUEST {

 

set client [IP::client_addr]

 

set request [HTTP::uri]

 

if {$request contains "login.aspx" and $request contains "?"}

 

{HTTP::uri {$request + "&IPAddress=" + $client}}

 

elseif {$request contains "login.aspx"}

 

{HTTP::uri {$request + "?IPAddress=" + $client}}

 

}

 

 

Really nice pseudo code, but obviously not syntactically correct. This results in the F5 sending a GET / $request + "IPAddress=" + $client to my server, which it's obviously not finding. So, how do I fix it?

 

 

Thanks!

 

-B

2 Replies

  • Try this:

    
    when HTTP_REQUEST {
      if { [string tolower [HTTP::uri]] contains "login.aspx" } {
        if { [HTTP::uri] contains "?"} {
          HTTP::uri "[HTTP::uri]&IPAddress=[IP::client_addr]"
        } else {
            HTTP::uri "[HTTP::uri]?IPAddress=[IP::client_addr]"
        }
      }
    }

    This passes syntax check, but is untested!
  • Thanks for the quick reply. I actually came up with this and successfully tested it a few minutes before I received your post:

     

     

    when HTTP_REQUEST {

     

    set request [HTTP::uri]

     

    if {$request contains "login.aspx" and $request contains "?"}

     

    {HTTP::uri "[HTTP::uri]&IPAddress=[IP::client_addr]"}

     

    elseif {$request contains "login.aspx"}

     

    {HTTP::uri "[HTTP::uri]?IPAddress=[IP::client_addr]"}

     

    }