Forum Discussion
peter_siman
Nimbostratus
May 30, 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
Sort By
- The_Bhattman
Nimbostratus
Hi Peter, - hoolio
Cirrostratus
As Bhattman said, [IP::server_addr] only works after a serverside connection has been established. You can use [LB::server] in the LB_SELECTED event when a load balancing selection has been made to get the selected server info. Or you can use [IP::server_addr] in or after SERVER_CONNECTED.when HTTP_REQUEST { log local0. "Erimo request received" if { [string tolower [HTTP::path]] equals "/aprimomarketing/login.aspx" } { log local0. "Erimo request for Aprimo service received. Selecting end server" pool Node_Web_ESESSMW1432 } else { pool wam_erimo_pool log local0. "Condition not matched. No Aprimo server selected." } } when SERVER_CONNECTED { log local0. "Connection from [IP::client_addr]:[TCP::client_port] to Aprimo server: [IP::server_addr]:[TCP::server_port] established." }
- Bob_10976
Nimbostratus
I'm trying to do this same thing, however using the code above and modifiy for me doesn't seem to work. I'm running ver 10.2.0 HF1, my code is below:when HTTP_REQUEST { log local0. "McBob request received" 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." }
- Michael_Yates
Nimbostratus
I tested a slightly modified version of your iRule and it worked fine for me. I think that the 404 that you are getting is an indication that it is working for you as well, but it is not finding the content that you are requesting from the server.when HTTP_REQUEST { log local0. "McBob request received" if { [string tolower [HTTP::path]] starts_with "/mcbob" } { log local0. "McBob request for service received. Selecting end server" pool secure2.mydomain.com HTTP::redirect "http://www.google.com" } else { log local0. "Condition not matched. No WIN2K8 server selected." pool secure.mydomain.com HTTP::redirect "http://www.yahoo.com" } } when SERVER_CONNECTED { log local0. "Connection from [IP::client_addr]:[TCP::client_port] to WIN2K8 server: [IP::server_addr]:[TCP::server_port] established." }
- Bob_10976
Nimbostratus
Michael... - The_Bhattman
Nimbostratus
Hi Bob, - Bob_10976
Nimbostratus
Correct, but only for this Rule. I have every day traffic using the secure2.mydomain.com pool currently. I have no problem accessing websites/applications that use the secure2.mydomain.com pool on a normal day, it only appears that the rule is not working when I attempt to redirect/switch traffic to that pool using this rule. - The_Bhattman
Nimbostratus
Hi Bob,when HTTP_REQUEST { switch -glob [HTTP::host] { "secure2.mydomain.com" { if { [HTTP::path] starts_with "/mcbob" } { log local0. "Accessed when the URL is http://[HTTP::host]/[HTTP::uri]" pool secure2.mydomain.com } "secure.mydomain.com" { log local0. "Accessed when the URL is http://[HTTP::host]/[HTTP::uri]" pool secure.mydomain.com } } } when SERVER_CONNECTED { log local0. "Connection from [IP::client_addr]:[TCP::client_port] to WIN2K8 server: [IP::server_addr]:[TCP::server_port] established." }
- Bob_10976
Nimbostratus
When I check the rule I recieve the following errors: - The_Bhattman
Nimbostratus
Hi Bob,
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