Forum Discussion
Shiraz
Altostratus
Dec 12, 2016Combining Two irules as one irule
Dears,
Any idea on combing the below two irules as one irule.
when HTTP_REQUEST {
if { ([IP::addr [client_addr] equals 12.x.x.0/24]) and ([HTTP::uri] contains "/something") } {
...
Vijay_E
Cirrus
Dec 12, 2016You can try this by creating 2 datagroups - CLASS_NETWORK with 12.x network and CLASS_DOMAIN_POOL that has the domain name as the "key" and the corresponding pool as the "value":
when CLIENT_ACCEPTED {
set DEFAULT [LB::server pool]
}
when HTTP_REQUEST {
if { ([HTTP::uri] contains "/something") } {
if { ([class match [IP::client_addr] equals CLASS_Network]) } {
pool something_http_pool
} else {
log local0. "_discard_something"
discard
}
} elseif { [class match [HTTP::host] eq CLASS_DOMAIN_POOL] } {
set POOL_SELECTED [class match -value [HTTP::host] contains CLASS_DOMAIN_POOL]
pool $POOL_SELECTED
} else {
pool $DEFAULT
}
}
I have never used "switch" within an if-statement but you can try to see if this will work by using "switch" within the "else" :
when HTTP_REQUEST {
if { ([HTTP::uri] contains "/something") } {
if { ([class match [IP::client_addr] equals CLASS_Network]) } {
pool something_http_pool
} else {
log local0. "_discard_something"
discard
}
} else {
switch [HTTP::host] {
"http-abc.xyz.com" { pool http_api_abc_test_pool }
"webportal-abc.xyz.com" { pool webportal_abc_test_pool }
"abc.xyz.com" { pool abc_test_pool }
"two-abc.xyz.com" { pool two_way_abc_test_pool }
"xml-api-abc.xyz.com" { pool xml_abc_test_pool }
"smpp-abc.xyz.com" { pool smpp_abc_test_pool }
}
}
}
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