Hi, we are trying to additional restrictions based on new IP and URL to existing rule… Below is an example of our current and also NEW iRule. does this look right? is there a better way to do this?
requirement: only source IP can access current allowed URI’s and this new URI. We are adding new IP to both “allow_IP” list
current iRule
when HTTP_REQUEST { if { [HTTP::host] starts_with “foo.com” } {
set show_flag 0
set allow_flag 0
Set the allow flag as required for each URI below
if { [HTTP::uri] starts_with "/gel/" } {
set allow_flag 1
} elseif { [HTTP::uri] equals "/water/" } {
set allow_flag 1
}
the below filters the URI by IP
if { [class match [IP::client_addr] equals allow_address_data_group ] } {
set show_flag 1
} else {
if { $allow_flag } {
set show_flag 1
}
}
if { $show_flag } {
if { [HTTP::uri] starts_with "/gel/" }{
pool secure_80_pool
} elseif { [HTTP::uri] starts_with "/water/" }{
pool secure_80_pool
} else {
HTTP::redirect "http://deafult-internal.net"
}
} else {
HTTP::redirect "http://default_external.com"
}
}
iRule with new restrictions
when HTTP_REQUEST { if { [HTTP::host] starts_with “foo.com” } {
set show_flag 0
set allow_flag 0
new flags for URI and IP respectively
set r1_flag 0
set r2_flag 0
Set the allow flag as required for each URI below
if { [HTTP::uri] starts_with "/gel/" } {
set allow_flag 1
} elseif { [HTTP::uri] equals "/water/" } {
set allow_flag 1
}
Set the allow flag for new URI
if { [HTTP::uri] starts_with "/new-URI/" } {
set r1_flag 1
}
the below filters the URI by IP
if { [class match [IP::client_addr] equals allow_address_data_group ] } {
set show_flag 1
} else {
if { $allow_flag } {
set show_flag 1
} else { [class match [IP::client_addr] equals new_allow_address_data_group ] } {
set r2_flag 1
} else {
if { $r1_flag } {
set r2_flag 1
}
if { $show_flag } {
if { [HTTP::uri] starts_with "/gel/" }{
pool secure_80_pool
} elseif { [HTTP::uri] starts_with "/water/" }{
pool secure_80_pool
} else {
if { $r2_flag } {
if { HTTP::uri] starts_with "/new-URI/" }{
pool secure_80_pool
} else {
HTTP::redirect "http://deafult-internal.net"
}
} else {
HTTP::redirect "http://www.default-external"
}
}