Forum Discussion

Victor_4983's avatar
Victor_4983
Icon for Nimbostratus rankNimbostratus
Sep 15, 2015

Removing Start Path of URI and direct to pool

Hi.

 

I am trying to remove part of the URI Path ($Path2), and pass the $Subpaths to a specific pool

 

http://example.com/$Path2/$Subpath1,$Subpath2 - (Remove $Path2 & pass $Subpaths through) Pass to Pool2

 

http://example.com/$Path1 Pass to Pool1

 

I am using F5 LTM 11.4.1 and need to create a Policy or iRULE to manipulate the URI.

 

Thanks in advance for any assistance.

 

4 Replies

  • Try this:

    when HTTP_REQUEST {
        Check the requested HTTP path
       switch -glob [string tolower [HTTP::path]] {
          "/path1/*" {
             pool pool1
           HTTP::path string map "/path1/ /" [HTTP::path]]  
          }
          "/path2/*" {
             pool pool2
           HTTP::path string map "/path2/ /" [HTTP::path]]  
          }
          default {
              o nothing
          }
       }
    }
    
  • Hello Stanislas.

     

    Thanks for your reply. I tried the following rule and it seemed to work. Not an iRULE expert so not sure which is the best option.

     

    when HTTP_REQUEST { if { [HTTP::uri] starts_with "/Path1" } { HTTP::uri [string map {"/Path1/" "/"} [HTTP::uri]] pool /Partition/Name_Port2 } else { pool /Partition/Name_Port2 } }

     

    Cheers, Victor

     

  • The switch is recommended if you have more than one condition based on the same variable.

    If you only have one condition as in your irule, you can use "if" instead of "switch"

    I advise you to use

    if { [string tolower [HTTP::uri]] starts_with "/path1" }
    to ignore the case.