Forum Discussion

Jeff_Wyant_4852's avatar
Jeff_Wyant_4852
Icon for Nimbostratus rankNimbostratus
Jun 19, 2006

Filter Mulitple Http Requests to Serveral Pools

I need an irule to filter traffic to send it to the correct pool (total of 3 pools) based on the URL. I have a start but need help with this irule.

 

 

when HTTP_REQUEST {

 

if { [HTTP::uri] contains "www.company.com" } {

 

pool company

 

}

 

}

 

when HTTP_REQUEST {

 

if { [HTTP::uri] contains "www.company.com/A" } {

 

pool company.net

 

}

 

}

 

when HTTP_REQUEST {

 

if { [HTTP::uri] contains "www.company/B" } {

 

pool company.com

 

} else {

 

pool company.com

 

}

 

}

1 Reply

  • There are a couple of issues here.

     

     

    First, you have three HTTP_REQUEST events in your rule. Consolidate all your logic into a single when statement.

     

     

    Second, here's the breakdown for a url

     

     

    http://www.foo.com/bar

     

    http://[HTTP::host][HTTP::uri]

     

     

    In this case [HTTP::host] would be "www.foo.com"

     

    and [HTTP::uri] would be "/bar".

     

     

    You are comparing the URI (HTTP::uri) to both the HTTP::host and HTTP::uri.

     

     

    You can either rearrange your logic to compare both the host and uri with a logical "and" or break it down into multiple if/elses. Or, if you want to be a real geek, go for a switch statement (search the forums for switch examples). If you get stuck, either search the forums or browse the CodeShare section of the iRules Wiki, there are a bunch of examples in there of exactly this functionality.

     

     

    -Joe