Forum Discussion
peter_siman
Nimbostratus
May 29, 2011Pool selection based on URI string
Hi,
I have writtend a simple iRule to select particular pool based on what the URI string is. See below the iRule. Unfortunatelly, when applied a following messsages show up in logs.
May 27 13:04:05 local/tmm3 info tmm3[7327]: Rule erimo_pool : Erimo request received
May 27 13:04:05 local/tmm3 info tmm3[7327]: Rule erimo_pool : Erimo request for Aprimo service received. Selecting end server
May 27 13:04:05 local/tmm3 err tmm3[7327]: 01220001:3: TCL error: erimo_pool - Error: No serverside connection established (line 1) invoked from within "IP::server_addr"
iRule:
when HTTP_REQUEST {
log local0. "Erimo request received"
if { [HTTP::path] equals "/AprimoMarketing/login.aspx" } {
log local0. "Erimo request for Aprimo service received. Selecting end server"
pool Node_Web_ESESSMW1432
log local0. "Aprimo end server selected: [IP::server_addr]"
}
else {
pool wam_erimo_pool
log local0. "Aprimo end server selected: [IP::server_addr]"
log local0. "Condition not matched. No Aprimo server selected. Server IP address is: [IP::server_addr]"
}
}
when SERVER_CONNECTED {
log local0. "Connection from[IP::client_addr]:[TCP::client_port] to Aprimo server:[IP::server_addr]:[TCP::server_port] established."
}
Does anyone have any idea what / where the issue might be?
Thanks.
17 Replies
- Bob_10976
Nimbostratus
That didn't seem to change anything, when I went to https://secure.mydomain.com/mcbob it was taken to my W2K3 server. I've even tried changing the pool from secure2.mydomain.com to another pool, or even one that doesn't exist, but everytime I'm NOT redirected to the pool listed, the only thing that seems to work is the redirect to a URL. Not sure if there is a bug or something fishy going on with my LTM.
I was doing a bit more research and was wondering if I could use the HTTP Class option, any thoughts on that?
Thanks,
Bob - The_Bhattman
Nimbostratus
Hi Bob,
I don't I am understanding what you mean by "NOT redirecting to the pool listed" Let's explain what the code I posted does. Then let me know where the logic doesn't work to what you want it to do.
The code I posted basically states that if a request comes in with https://secure2.mydomain.com/mcbob or https://secure2.mydomain.com/mcbobandstuff it will forward the request to pool secure2.mydomain.com. If the request is https://secure.mydomain.com/ or https://secure.mydomain.com/mcbob or https://secure.mydomain.com/blahblah it will go to pool secure.mydomain.com. If a request comes to the vip as https://secure3.mydomain.com/ it will not match the switch and IF statements and thus rely on the default pool that you have set in the virtual address.
I hope somewhere in my explaination clarifies what the code is doing vs what you want it do.
Bhattman - Bob_10976
Nimbostratus
Thanks for the explaination.. When I say Not redireting to the pool listed, I mean it is not using the Pool that that is listed, in this case secure2.mydomain.com, when the path is matched. Sorry, redirected was probably not the best term. I should have said not being forwarded to the pool secure2.mydomain.com.
What I'm looking for this rule to do is if I go to https://secure.mydomain.com/mcbob then it uses the secure2.mydomain.com pool, if the path is not /mcbob then use the secure.mydomain.com pool. The McBob website exist on both my W2K3 and my W2K8 servers. The W2K3 server uses secure.mydomain.com Pool and the secure2.mydomain.com pool consist of my W2K8 server. We are starting to move some of our apps from our old W2K3 servers over to our new W2K8 servers but not all of them exist there yet, so as I migrate them, one at a time, I simply want a rule that when the path matches go to the W2K8 server, which is the secure2.mydomain.com pool. All of our secure apps are setup for a URL like: https://secure.mydomain.com/something.
The https://secure2.mydomain.com Domain/URL was created only to be used internally for testing apps from outside our network, end users/customers will not use that URL.
Maybe there is a better way to go about this and I'm over looking it, but this rule seems like my best solution as I migrate apps from one server to another.
Thanks,
Bob - Bob_10976
Nimbostratus
Thanks everyone for the help with this rule, I found that I had an http class assoicated to the VIP that was overwritting the irule. Once I removed the http class it worked as expected, I guess sometimes it just those things you over look.
I did have one more follow up question though. My rule works when the path is matched but it appears that I may have to add another paths as well. How would I modify the rule so that it checks more than one path? I've copied the rule below so you can see what I have currently.when HTTP_REQUEST { log local0. "McBob request received [string tolower [HTTP::uri]] starts_with /mcbob" if { [string tolower [HTTP::path]] starts_with "/mcbob" } { log local0. "McBob request for service received. Selecting end server" pool secure2.mydomain.com } else { pool secure.mydomain.com log local0. "Condition not matched. No WIN2K8 server selected." } } when SERVER_CONNECTED { log local0. "Connection from [IP::client_addr]:[TCP::client_port] to WIN2K8 server: [IP::server_addr]:[TCP::server_port] established." }
Thanks again for everyone's input.
Bob - The_Bhattman
Nimbostratus
Hi Bob,
There are 2 ways to go about this. You can use the switch statement if there is small list of paths you want to check for or you can can use class objects
Here is the switch commandwhen HTTP_REQUEST { switch -glob [string tolower[HTTP::path] ] { "/mcbob*" - "/path2*" - "/path3*" { pool secure2.mydomain.com } default { pool secure2.mydomain.com } } }
Or you can use datagroups which works well when you have lots of different paths you want to take into account
class mypaths {
"/mcbob"
"/path1"
"/path2"
"/path3"
}when HTTP_REQUEST { if {[class match -value [string tolower [HTTP::path]] starts_with "mypaths" ] } { pool secure2.mydomain.com } else { pool secure.mydomain.com } }
Note: This is untested code
I hope this helps
@Bhattman - Bob_10976
Nimbostratus
Thanks for all the help, the switch command should work, hopefully this is only going to be for a few Apps..
Bob - jba3126
Cirrostratus
Hi All, I have a similar item I'm working with the exception I'm not doing any logging. In short we are going from SharePoint 2007 to 2010. To ease the pain of migrating sites I suggested we use the F5 LTMs to redirect based on the URI. I attempted this with a http class until I discovered that SharePoint checks the host name in the HTTP header. I've been told we might have as many as 30 URIs/Paths to redirect to the old 2007 instance and will need to remove them from the list so to speak as they migrate to 2010. I've done my very best to try to piece together a script that will do the trick and unfortunately I'm falling short 😞
Summary:
http://www.abc.com
/uri1
/uri2
/uri3
/uri4
etc. needs to go to sharepoint2007pool and change host from www.abc.com to www.xyz.com. Everything else needs to go to sharepoint2010pool with no host change.
Here is my attempt to accomplish:when HTTP_REQUEST { switch -glob [HTTP::path] if { [HTTP::path]] "/sites/dts*" } { Rewrite host header value and select pool HTTP::header replace Host www.xyz.com pool sharepoing2007pool } else { pool sharepoint2010pool } }
For ease of adding and removing multiple sites, I'm very interested in how I might use the datagroups. That would make it much easier for me to add and remove sites as needed.
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