Forum Discussion
Darren_21048
Nimbostratus
Jul 10, 2009URI Pool Redirect Question
Hi everyone,
Complete newbie here. I want to create an iRule that redirects to another pool based on the URI. So if I get a request for www.domain.com/xyz/, the request goes to the pool configured for that address, but if the request is for www.domain.com/abc/, the request redirects to another pool.
From reading this forum, it looks like it's as simple as the code below but am I missing something? Any help much appreciated. Thanks.
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/abc" } {
pool abc_pool
}
}
6 Replies
- hoolio
Cirrostratus
That looks good. You should either add a OneConnect profile (Click here) to the virtual server or put an else statement in the iRule. Either option would ensure subsequent requests on the same TCP connection are sent to the correct pool based on the iRule logic.
Aaron - Darren_21048
Nimbostratus
Hi Aaron,
Thanks for the quick response and information. I've had a read about OneConnect and we have fairly specific logging requirements at present, I think I'll look at that in more detail in future. I'd like to add the 'Else' statement as you suggest but the web farm I run is not small and we run around 400 domains split accross multiple pools. So www.domain1.com points at pool1 and and www.domain2.com points at pool2 etc. Can I word the 'Else' statement to pass the request to the original pool rather than a specific pool if the condition is not met? - hoolio
Cirrostratus
You can get the VS's default pool using LB::server in CLIENT_ACCEPTED, so this should suit your needs:when CLIENT_ACCEPTED { Save the default pool name set default_pool [LB::server] } when HTTP_REQUEST { if { [HTTP::uri] starts_with "/abc" } { pool abc_pool } else { pool $default_pool } }
You can specify a source netmask on a OneConnect profile of 255.255.255.255 to ensure only the same client IP address reuses a server side TCP connection.
Aaron - Darren_21048
Nimbostratus
I'll test that next week, thanks again.
Darren - Darren_21048
Nimbostratus
That works fine though I've modified it slightly as I wasn't dealing with case.when CLIENT_ACCEPTED { Save the default pool name set default_pool [LB::server] } when HTTP_REQUEST { if {[string tolower [HTTP::uri]} starts_with "/abc" } { pool abc_pool } else { pool $default_pool } }
I'm looking into this now but I have some URL's with /abcd and /abcd.aspx for example that I do not want to redirect, I only want to redirect /abc or /abc/. If someone has a quick answer, please feel free to post. Thanks. - Darren_21048
Nimbostratus
Will this do the trick?when CLIENT_ACCEPTED { Save the default pool name set default_pool [LB::server] } when HTTP_REQUEST { if {[string tolower [URI::path [HTTP::uri] 1 1] equals "/abc" } { pool abc_pool } else { pool $default_pool } }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
