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
}
}
- 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. - Darren_21048
Nimbostratus
Hi Aaron, - 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 } }
- Darren_21048
Nimbostratus
I'll test that next week, thanks again. - 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 } }
- 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