Forum Discussion
David_Robert_11
Nimbostratus
Mar 11, 2010uri and pool redirection
Hi,
I think there may be an easy way to do this, I can get some of it to work, but not all of it.
We have a need to redirect traffic to a different pool, based off...
hoolio
Cirrostratus
Mar 11, 2010Hi David,
So you basically want www.xyz.com/site2 requests to be redirected to www2.xyz.com/site2, www2.xyz.com/site2 requests to go to pool2 and all other requests to go to pool1? If so, can you try this?
when HTTP_REQUEST {
log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] request to [HTTP::host][HTTP::uri]"
Check the requested host header
switch [string tolower [HTTP::host]] {
"www.xyz.com" {
Request was for www.xyz.com. Check if the URI starts with /site2
if {[HTTP::path] starts_with "/site2"}{
Redirect client to www2.xyz.com with the original URI
log local0. "[IP::client_addr]:[TCP::client_port]: www.xyz.com/site2 request, redirecting."
HTTP::redirect "http://www2.xyz.com[HTTP::uri]"
} else {
Not a /site2 URI, so use pool1
log local0. "[IP::client_addr]:[TCP::client_port]: www.xyz.com non-site2 request, using pool1."
pool pool1
}
}
"www2.xyz.com" {
Request was for www2.xyz.com. Use pool2
log local0. "[IP::client_addr]:[TCP::client_port]: www2.xyz.com request, using pool2."
pool pool2
}
default {
Take some default action for other hosts?
log local0. "[IP::client_addr]:[TCP::client_port]: No host match."
}
}
}
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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