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 of the uri. so.
http:\\www.xyz.com\Site1 goes to Pool1, however, if this uri comes in http:\\www.xyz.com\Site2, it should get redirected to http:\\www2.xyz.com\Site2 and go to Pool2, but all other traffic should stay with http:\\www.xyz.com\ and with Pool1
Any ideas how this may work?
- hoolio
Cirrostratus
Hi David,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." } } }
- The_Bhattman
Nimbostratus
Hi David,when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/site2" {pool pool2 } default {pool pool1 } } }
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/site2" {pool pool2 } } }
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/site2" {HTTP::redirect "http:\\www2.xyz.com\Site2" } default {pool pool1 } } }
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/site2" {HTTP::redirect "http:\\www2.xyz.com\Site2" } } }
- David_Robert_11
Nimbostratus
Hi,
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