Forum Discussion

John_Lin_106399's avatar
John_Lin_106399
Icon for Nimbostratus rankNimbostratus
Jan 04, 2007

URI rewrite to pool?

I'm looking at our current iRules which so a URI check and sends it to proper pools preserving the URI but now we need to send it to a particular pool with different URI.

 

 

My iRule looks likes below

 

 

when HTTP_REQUEST {

 

if { [HTTP::uri] starts_with "/a/" } {

 

pool PoolA }

 

elseif { [HTTP::uri] starts_with "/b/" }

 

{ pool PoolB}

 

}

 

 

But if I want traffic that starts with /b/ to goto PoolB but instead of passing "/b/*" as request pass say "/c/*"

 

What is the proper way to do this while still preserving what goes after the /b/ ?

 

 

Please advise

7 Replies

  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Thanks for the info, bl0ndie. Nice adds.

     

    Any idea in which version those were added?

     

     

    thanks!

     

    /deb
  • bl0ndie_127134's avatar
    bl0ndie_127134
    Historic F5 Account
    Oh I forgot to mention that we also added a query parser that returns the parameter value.

    
    URI::query 

  • Hi Blondie,

    When I try: [URI::query "param"] with or without the double quotes, I get nothing back from a request with a parameter called 'param':

    
    [HTTP::uri]                   - /path/to/a/file.ext;session_id=abcdefgh?param=value
    [URI::path [HTTP::uri]]       - /path/to/a/
    [URI::path [HTTP::uri] 2 10]  - /to/a/
    [URI::path [HTTP::uri] 1]     - /path/to/a/
    [URI::path [HTTP::uri] depth] - 3
    [HTTP::path]                  - /path/to/a/file.ext;session_id=abcdefgh
    [HTTP::query]                 - param=value
    [URI::query "param"]          -

    Am I missing something?

    Thanks,

    Aaron
  • bl0ndie_127134's avatar
    bl0ndie_127134
    Historic F5 Account
    This can be really useful when you have multiple parameters like this ....

    
    [HTTP::uri]                           - /path/to/a/file.ext?para1=val1&para2=value2&para3=value3&para4=value4
    [URI::query [HTTP::uri] "para3"]      - value3

  • I just added a sample to code share that illustrates interrogating the URI with all the above mentioned methods.

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/URIInterrogation.html

     

    Click here

     

     

    Unfortunately I don't think there is a method to get a list of all parameters in the query string so I was forced to do a couple of string splits to extract the names.

     

     

    Enjoy!

     

     

    -Joe