Forum Discussion

Earvin_247775's avatar
Earvin_247775
Icon for Altocumulus rankAltocumulus
Feb 03, 2017

Question regarding irule http::uri to select pool based on URI

Hi Everyone,

 

Please help me solve my problem regarding iRule to select pool based on URI. Here is the Scenario:

 

if the uri equals /ez/x=ez&xt=bal or /ez/x=ez&xt=cup it will go to poolA if the uri starts with /ez, it will go to poolB else reject

 

I used datagroup list to get the value of URI.

 

results: 1. whenever i typed uri /sm/x=ez&xt=bal, it was rejected as expected 2. whenever i typed /ez/123 will be directed to pool B as expected. 3. but when i typed the one I defined for poolA (/ez/x=ez&xt=bal or /ez/x=ez&xt=cup) i was also redirected to poolB

 

I am new to iRules. please help me. here is my config. i tried to use "else if" but not accepted by syntax.

 

iRule:

 

priority 400 when HTTP_REQUEST { if { [class match [string tolower [HTTP::path]] equals "ezPath" ]}{ pool RS_STAGING_10.128.56.164 log local0. "Request: [HTTP::uri] first conidtion" } if { [class match [string tolower [HTTP::path]] starts_with "ezOnly" ]}{ pool RS_STAGING_10.128.115.183 log local0. "Request: [HTTP::uri] 2nd condition" } else { reject log local0. "This is rejected" log local0. "Request: [HTTP::uri]" } } priority 600 when LB_SELECTED { log local0. "[LB::server addr] was the IP that was selected." }

 

Datagroup List:

 

ezPath: /ez/x=ez&xt=bal:=RS_STAGING_10.128.56.164 /ez/x=ez&xt=cup:=RS_STAGING_10.128.56.164

 

ezOnly: /ez:=RS_STAGING_10.128.115.183

 

  • This was resolved by replacing the second condition "if" by "elseif".

     

    At first I was trying "else if". That space should be omitted.

     

    hahaha.

     

    Thank you anyway!

     

  • This was resolved by replacing the second condition "if" by "elseif".

     

    At first I was trying "else if". That space should be omitted.

     

    hahaha.

     

    Thank you anyway!