Forum Discussion

Sabir_Alvi's avatar
Sabir_Alvi
Icon for Altocumulus rankAltocumulus
Mar 08, 2018

iRule with host and uri match condition

I need an iRule that should check host and uri combination and redirect to appropriate pool. Below is what I have but its not working.

when HTTP_REQUEST {
  set pool [class match -value -- [HTTP::host][HTTP::uri] equals test_url_attachment]
  if {$pool ne ""} {
    pool $pool
  }
}

example1.com/attachment should go to example1.com pool

example2.com/attachment should go to example2.com pool

example3.com/attachment should go to example3.com pool

test_url_attachment is the datagroup that has string and value as below --

example1.com/attachment* -- value example1.com
example2.com/attachment* -- value example2.com
example3.com/attachment* -- value example3.com

URI will remain common for all and I need to have the iRule this way based on URI, as it works only on a specific port (our app requirement). I have another iRule that maps based on just host to appr pool on diff port.

Please advise on how to the syntax as the request is not reaching the pool with what I have.

1 Reply

  • You must remove wildcards in datagroup keys are they are interpreted as the * character and not a wildcard.

    Then, change condition in class match

    set pool [class match -value -- [HTTP::host][HTTP::uri] starts_with test_url_attachment]