Forum Discussion
Neeraj_Jags_152
Cirrus
Jul 10, 2014HTTP_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. ...
Neeraj_Jags_152
Cirrus
Jul 15, 2014Hi Kevin, thanks, I tried as you suggested and is working fine.
Now I will convert it to use Data Group and to switch to specified pool or to default pool.
my final https version reduced.
when HTTP_REQUEST {
log local0. "https.1st Client ([IP::client_addr]) is requesting: [HTTP::path]"
if { ([IP::addr [IP::client_addr] equals 176.203.127.xx%1701]) or ([IP::addr [IP::client_addr] equals 176.203.95.xx%1701]) or ([IP::addr [IP::client_addr] equals 78.100.153.xx%1701]) } {
log local0. "https SRC IP matched [IP::client_addr], so look if word match"
switch -glob [string tolower [HTTP::path]] {
"/use/*" {
log local0. "https Catch1 word: use, "
}
"/use2/*" {
log local0. "https Catch2 word: use2, so no redirect"
HTTP::respond 200 content "IP is [IP::client_addr] and use2" "Content-Type" "text"
}
"/oncfo/*" {
log local0. "https Catch3 word: oncfo, "
}
"/oncfo2/*" {
log local0. "https Catch4 word: oncfo2, so no redirect"
HTTP::respond 200 content "IP is [IP::client_addr] and oncfo2" "Content-Type" "text/xml"
}
default {
log local0. "Default https, IP is [IP::client_addr] matched but [HTTP::path]"
return
}
}
} else {
log local0. "https SRC IP [IP::client_addr] doesn't match and word is [HTTP::path]"
return
}
}
I hope you agrees to that. Thanks again...
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