Forum Discussion
Selecting another Virtual from and iRule of one Virtual ? URI based routing ?
Hi guys,
Is there a way that we can select new virtual from the iRule of one Virtual server? i tried "LB::reselect virtual vs1" but it didn't worked.
I am trying to implement URI based routing between two apps ( website/vip1 || website/vip2 should go to one app1 and everything else should go to another app2)
app1 is a webapplications which has its own iRule which does some additional tasks like inserting new headers and some redirects
app2 is just a static web site
here is the first iRule
when HTTP_REQUEST {
if {
([HTTP::uri] starts_with "/vip1") ||
([HTTP::uri] starts_with "/vip2")
} then {
pool pool1
} else {
pool pool2
}
}
when LB_SELECTED {
log local0. "[LB::server addr] is selected"
if {
([LB::server addr] eq "192.168.68.46") ||
([LB::server addr] eq "192.168.68.45")
} then {
log local0. "[LB::server addr] is selected"
LB::reselect virtual vs2
} } `
5 Replies
- hoolio
Cirrostratus
You should be able to just use the virtual command without LB::reselect:
https://devcentral.f5.com/wiki/iRules.virtual.ashx
Aaron
- msdatla_64383
Nimbostratus
Thanks Aaron for a quick answer, appreciate it.
But the virtual vs2 is not getting the request if you do so
When you go directly to vs2, it is serving the request (autoSNAT is enabled on both, also CMP is also enabled on both)
i also modifed the iRule to look like this, which should have same affect, same thing happens here as well.
when HTTP_REQUEST { if { ([HTTP::uri] starts_with "/vip1") || ([HTTP::uri] starts_with "/vip2") } then { virtual vs2 } else { pool pool2 } } - Kevin_Stewart
Employee
Minor update to your code:
when HTTP_REQUEST { if { ( [HTTP::uri] starts_with "/vip1" ) || ( [HTTP::uri] starts_with "/vip2" ) } { virtual vs2 } else { pool pool2 } }Does this work?
- Kevin_Stewart
Employee
Try this:
when HTTP_REQUEST { log local0. "URI = [HTTP::uri]" if { ( [string tolower [HTTP::uri]] starts_with "/vip1" ) or ( [string tolower [HTTP::uri]] starts_with "/vip2" ) } { log local0. "Going to virtual vs2" virtual vs2 } else { log local0. "Going to pool pool2" pool pool2 } }Then from the command line:
tail -f /var/log/ltm - Kevin_Stewart
Employee
Any chance your internal virtual (vs2) is using a client SSL profile? And you're not using a server SSL profile on the external VIP? Try this just to simplify things:
when HTTP_REQUEST { virtual vs2 }Then just purposefully go to "/vip1" to test. Does this get you to the internal VIP?
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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