Forum Discussion
NewTOF501_15047
Nimbostratus
Apr 10, 2014irule which check if uri contains services
I need a irule which check if uri contains services like http://domain.name.com/services" or "oservices" then send traffic to service_pool or oservice_pool but before that it should change uri to /wp...
a_pavlov_114144
Cirrus
Apr 10, 2014You should assign something like the following iRule to your virtual server:
when HTTP_REQUEST {
if { [HTTP::uri] contains "services" } {
HTTP::redirect "/wps/portal"
pool SERVICE_POOL
}
elseif { [HTTP::uri] contains "oservices" } {
HTTP::redirect "/wps/portal"
pool OSERVICE_POOL
}
}
- NewTOF501_15047Apr 10, 2014
Nimbostratus
Thanks. I tried but it is sending traffic to default pool not to member of service_pool - a_pavlov_114144Apr 10, 2014
Cirrus
You can add some logging to your irule to make sure that conditions in if statement work fine. And then look in /var/log/ltm for your messages. Like this: when HTTP_REQUEST { log local0. "URI = [HTTP::uri]" if { [HTTP::uri] contains "services" } { HTTP::redirect "/wps/portal" pool SERVICE_POOL log local0. "SERVICE POOL" } elseif { [HTTP::uri] contains "oservices" } { HTTP::redirect "/wps/portal" pool OSERVICE_POOL log local0. "OSERVICE_POOL" } } - NewTOF501_15047Apr 10, 2014
Nimbostratus
I added log local0 but nothing appearing in /var/log/ltm - a_pavlov_114144Apr 10, 2014
Cirrus
Even the string with URI? log local0. "URI = [HTTP::uri]" - this should work on every HTTP Request. Are you sure you have assigned this iRule to virtual server? - NewTOF501_15047Apr 10, 2014
Nimbostratus
sorry i found log it says below. why request /wps/portal is not going to member of SERVICE POOL Apr 10 11:26:01 CIODCDMZF5LTM02 info tmm2[10306]: Rule /Common/services.portal : URI = /services Apr 10 11:26:01 CIODCDMZF5LTM02 info tmm2[10306]: Rule /Common/services.portal : SERVICE POOL Apr 10 11:26:01 CIODCDMZF5LTM02 info tmm2[10306]: Rule /Common/services.portal : URI = /wps/portal - a_pavlov_114144Apr 10, 2014
Cirrus
I see. The problem is that we shouldn't use redirect here. Then iRule should be the following: when HTTP_REQUEST { log local0. "URI = [HTTP::uri]" if { [HTTP::uri] contains "services" } { HTTP::uri "/wps/portal" pool SERVICE_POOL log local0. "SERVICE POOL" } elseif { [HTTP::uri] contains "oservices" } { HTTP::uri "/wps/portal" pool OSERVICE_POOL log local0. "OSERVICE_POOL" } } - NewTOF501_15047Apr 10, 2014
Nimbostratus
Thanks but still same problem Apr 10 11:41:56 CIODCDMZF5LTM02 info tmm7[10306]: Rule /Common/services.portal : URI = /services Apr 10 11:41:56 CIODCDMZF5LTM02 info tmm7[10306]: Rule /Common/services.portal : tstsrv_Pool_http Apr 10 11:41:56 CIODCDMZF5LTM02 info tmm7[10306]: Rule /Common/services.portal : URI = /wps/portal/!ut/p/a1/04_Sj9CPykssy0xPLMnMz0vMAfGjzOItLNydDY0sjLzcTcOMDBxNLE0sLcNMjQwMTIEKIoEKDHAARwNC-sP1o8BKnN0dPUzMfYB6TCyMDDxdnDxczC19DQw8zaAK8FhRkBthkOmoqAgAqk60hg!!/dl5/d5/L2dBISEvZ0FBIS9nQSEh/ - a_pavlov_114144Apr 10, 2014
Cirrus
Hm, this is strange. Try this one, let's see what's going wrong: when HTTP_REQUEST { log local0. "URI = [HTTP::uri]" if { [HTTP::uri] contains "services" } { log local0. "URI CONTAINS SERVICES" HTTP::uri "/wps/portal" pool SERVICE_POOL log local0. "SERVICE POOL" } elseif { [HTTP::uri] contains "oservices" } { log local0. "URI CONTAINS OSERVICES" HTTP::uri "/wps/portal" pool OSERVICE_POOL log local0. "OSERVICE_POOL" } else { log local0. "DEFAULT POOL" } } - NewTOF501_15047Apr 10, 2014
Nimbostratus
Thanks again after change below are log Apr 10 12:41:39 CIODCDMZF5LTM02 info tmm7[10306]: Rule /Common/services.portal : URI = /services Apr 10 12:41:39 CIODCDMZF5LTM02 info tmm7[10306]: Rule /Common/services.portal : URI CONTAINS SERVICES Apr 10 12:41:39 CIODCDMZF5LTM02 info tmm7[10306]: Rule /Common/services.portal : SERVICE POOL - a_pavlov_114144Apr 10, 2014
Cirrus
So, I suppose it should work. Is it not?
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
