Forum Discussion
janardhan123_20
Nimbostratus
Aug 27, 2015Route request to new pool based on IP range & URI matches
Hello,
We have a original iRule which routes the requests based on URI matches.
We would need add below logics in current iRule.
1) Both IP matches & URI( I.e /welcome) matches route only those...
Stanislas_Piro2
Cumulonimbus
Aug 27, 2015Hi,
try this irule:
when RULE_INIT {
create static variables instead of creating variable on each HTTP Request event
set static::cookie_match "test_73686f70123c"
set static::cookie_default "73686f70123c"
set static::cookie_null [format "73686f70123c=deleted; path=/; Expires=Thurs, 01-Jan-1970 00:00:00 GMT;"]
Log debug messages to /var/log/ltm ? 1=yes, 0=no
set static::var_debug 1
}
when HTTP_REQUEST {
set testSession 0
if { not [class match [IP::client_addr] equals class_IP_list] } {
set is_ip_allowed 0
} else {
set is_ip_allowed 1
if {[HTTP::cookie exists $static::cookie_match]} {
set testSession 1
persist cookie insert $static::cookie_match pool
pool_abc_http
return added
}
}
switch -glob [string tolower [HTTP::uri]] {
"*welcome*" -
"*test*" {
if {$is_ip_allowed} {
if {$static::var_debug}{log local0. "client IP <[IP::client_addr]> matching allowed IP for URI [HTTP::uri]"}
persist cookie insert $static::cookie_match 0
pool pool_abc.com_http
set testSession 0
} else {
if {$static::var_debug}{log local0. "Reject : client IP <[IP::client_addr]> not matching allowed IP for URI [HTTP::uri]"}
reject
}
}
}
}
when HTTP_RESPONSE {
Insert persistent cookie for html content type and private session
if {$testSession} {
HTTP::cookie remove $static::cookie_default
HTTP::header insert Set-Cookie $static::cookie_null
}
}
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
