Forum Discussion

Thomas_89706's avatar
Thomas_89706
Icon for Nimbostratus rankNimbostratus
May 17, 2007

In need of some iRule HELP!! URI Path stuff.

I'm trying to take the first path in the URI and direct it to a specific pool if it contains a specific string. For some reason my iRule below is directing all traffic to my catch all pool even if it meets the criteria set. Please help me I'm not sure what I'm doing wrong.

 

 

testing URL: "http://192.168.1.1/b02181/1.jsp"

 

jsp returns the machine name that it hits every time it goes to my pl_2 machine.

 

 

iRule:

 

when HTTP_REQUEST {

 

set CSID [string tolower [URI::path [HTTP::uri] 1 1]]

 

if { ([ $CSID] equals "b02181") or ( [$CSID] equals "h05527") } {

 

pool pl_1

 

} else {

 

pool pl_2

 

}

 

}

 

 

 

If my iRule has "/" in the beginning and end of the string compares it fails totally.

3 Replies

  • Also will take any advise to having a list of CSIDs that it can check against like walk through an array and see if there is a string that matchs the CSID and then go to pl_1 if no match then go to pl_2.
  • Remove the brackets around your variables for starters:

    
    if { ($CSID equals "b02181") or ($CSID equals "h05527") } {
  • You can build a class of your CSID's then reference your class for pool pl_1 inclusion:

    
    class myCSID {
     "b02181"
     "h05527"
    }
    when HTTP_REQUEST {
      set CSID [string tolower [URI::path [HTTP::uri] 1 1]]
      if { [matchclass $CSID equals $::myCSID] } {
        pool pl_1
      } else {
          pool pl_2
      }
    }

    If you ever had more pools, you could alter the class to include the pool reference, then use findclass to extract it:

    
    class myCSID {
      "b02181 pl_1"
      "h05527 pl_1"
      "x07770 pl_2"
      "y07070 pl_3"
    }
    when HTTP_REQUEST {
      set CSID [string tolower [URI::path [HTTP::uri] 1 1]]
      if { [matchclass $CSID equals $::myCSID] } {
        pool [findclass $CSID $::myCSID " "]
      } else {
          pool defaultPool
      }
    }

    HTH, std disclaimer....untested!