Forum Discussion
How to Block all traffic that doesn't start with certain string question
Hello,
I'm trying to block all traffic that doesn't start with a certain string. I've wrote the iRule below but it's not working. Does anyone have any hints or tips? My iRule is probably more complicated than it needs to be but I feel like it should work.
when HTTP_REQUEST {
if { [HTTP::path ] starts_with "/CHD"} {
pool
}
elseif {not [HTTP::path ] starts_with "/CHD"}{
HTTP::respond 403 content {Blocked!}
}
}
4 Replies
- Blogger11_11505
Nimbostratus
Wow, I have no idea why the forum messed up the formatting on that. Here is my iRule:
when HTTP_REQUEST { if { [HTTP::path ] starts_with "/CHD"} { pool pool_soa_wservicetst_80 } elseif {not [HTTP::path ] starts_with "/CHD"}{ HTTP::respond 403 content {Blocked!} } }
- Blogger11_11505
Nimbostratus
Code when HTTP_REQUEST { if { [HTTP::path ] starts_with "/CHD"} { pool pool_soa_wservicetst_80 } elseif {not [HTTP::path ] starts_with "/CHD"}{ HTTP::respond 403 content {Blocked!} } } - JRahm
Admin
does the case matter on that path? what if it comes in /chd, is that still ok?
This should work (assumes pool pool_soa_wservicetst_80 is the default pool):
when HTTP_REQUEST { if { not([string tolower [HTTP::path]] starts_with "/chd") } { HTTP::respond 403 content "Blocked!" } } - Blogger11_11505
Nimbostratus
Yes case matters, CHD needs to be all uppercase
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
