Forum Discussion

JHally_43299's avatar
JHally_43299
Icon for Nimbostratus rankNimbostratus
Aug 16, 2012

HTTPS iRule to map requests to different pools

Hi All,

 

 

I have a virtual which I want to direct default traffic to PoolA, but any requests for a specfic directory to another pool. I can do this currently with the following iRule on a virtual for HTTP and it seems to work fine if I set a default pool then add this iRule to the virtual:

 

 

 

when HTTP_REQUEST {

 

switch -glob [HTTP::host][HTTP::uri] {

 

"*.somedomain.com/dir1/*" { pool dir1-pool }

 

}

 

}

 

 

 

 

I want to do the same thing for HTTPS requests and I have set up a second virtual with the same default pool and added an SSL client profile to terminate SSL at the LTM, but I'm not sure its working correctly.

 

 

 

has anyone done something similar?

 

 

 

thanks!

 

 

 

John

 

  • Hi JHally,

     

     

    Yes it should work for both HTTP and HTTPS in the case you mentioned, try the below iRule in both HTTP and HTTPS

     

     

    when HTTP_REQUEST {

     

    if {[string tolower [HTTP::host]] contains "somedomain.com"} {

     

    switch -glob [string tolower [HTTP::uri]] {

     

    "/dir1/*" { pool dir1-pool }

     

    default { pool default-pool }

     

    }

     

    }

     

    }

     

     

    Aaron (hoolio) has highlighted very important point if you have an iRule selecting a pool, to enable OneConnect profile to the VS to ensure each HTTP/HTTPS request is load balanced to the correct pool.

     

     

    the post: https://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/aft/2163946/showtab/groupforums/Default.aspx

     

     

    the link: https://devcentral.f5.com/wiki/AdvDesignConfig.ONECONNECT.ashx

     

     

    HTH

     

     

    BR,

     

    Abdul