For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Neeraj_Jags_152's avatar
Jul 10, 2014

HTTP_REQUEST and HTTP::redirect and HTTP::respond with if condition and source IP

I have below iRule but it is not working as expected. two statement working /oncfo1/ and /oncres1/ but /use1/ not forwarding & also if no condition match then else statement also not giving result.

 

I want. if for particular source IP from internet and if access a host with three sub directories then redirect to accordingly but other then these sub directory, it should return content with some message.

 

when HTTP_REQUEST { set src_clint_ip [IP::client_addr] set host [string tolower [getfield [HTTP::host] ":" 1]] set path [string tolower [HTTP::path]]

 

log local0. "client=[IP::client_addr] host=[HTTP::host] path=$path"

 

if {( [IP::addr $src_clint_ip equals 176.202.126.81%1701] )} then { if { $path starts_with "/use1/" } then { HTTP::redirect "https://ecr.host.com.qa/use/" HTTP::respond 200 content "IP is $src_client_ip and /use1/" "Content-Type" "text/xml" } elseif { $path starts_with "/oncfo1/" } then { HTTP::redirect "https://ecr.host.com.qa/oncfo/" HTTP::respond 200 content "IP is $src_client_ip and /oncfo/" "Content-Type" "text/xml" } elseif { $path starts_with "/oncres1/" } then { HTTP::redirect https://ecr.host.com.qa/oncres/

 

HTTP::respond 200 content "IP is $src_client_ip and /oncres/" "Content-Type" "text/xml" } else { HTTP::respond 200 content "IP is $src_client_ip and not matching" "Content-Type" "text/xml" }

 

} else { HTTP::respond 200 content "IP is $src_client_ip and check it" "Content-Type" "text/xml" } unset src_clint_ip }

 

26 Replies