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?
3 Replies
- hoolio
Cirrostratus
Hi 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 - The_Bhattman
Nimbostratus
Hi David,
I am assuming that www2.xyz.com and www.xyz.com are pointing to the same VIP.
Based on this you can do the followingwhen HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/site2" {pool pool2 } default {pool pool1 } } }
or if you assign pool1 as the default pool then you can also right it aswhen HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/site2" {pool pool2 } } }
--------------
if http://www2.xyz.com/site2 is pointing a seperate vip then the iRule would look something like the following:when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/site2" {HTTP::redirect "http:\\www2.xyz.com\Site2" } default {pool pool1 } } }
or if you assign pool1 as the default pool then you can also right it aswhen HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/site2" {HTTP::redirect "http:\\www2.xyz.com\Site2" } } }
I hope this helps
Bhattman - David_Robert_11
Nimbostratus
Hi,
Thank you for the reply's.
It started out as a simple redirect that almost works. If user went to http:\\www.xyz.com\anysite they would get the default web pool and everything is good. However, they want to use the same name, but a different site is to go to a different pool. So, http:\\www.xyz.com\diffsite would redirect to a different pool via an irule. That worked. However, some code in the application would contain references to the default site "http:\\www.xyz.com\" and fail since the default site isn't serving up the same app, (but they are the same app, just differnent versions). So, the thought was, have the second server/pool serve up www2.xzy.com, and try and have all the traffic get routed to that new pool.
So, I think I'm trying to do two things, hit the default site and based of off \sitename do a redirect to a different host name, which is then matched to a different pool. I am hoping the logic in this I-rule will work to allow that?
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