Forum Discussion
Brian_Mayer_841
Nimbostratus
Aug 19, 2008Conditional logic based on source IP
Hi guys,
We'd like to implement an iRule that triggers on the presence of two or three specific strings in the URI. When any of the strings are found, we next want to check the source ...
hoolio
Cirrostratus
Aug 26, 2008If you want to check the URI for one string, you wouldn't reference the class or use matchclass. Also, if the above examples aren't working, break each check into a separate 'if' statement and add logging to figure out what's happening.
when HTTP_REQUEST {
log local0. "[IP::client_addr]:[TCP::client_port]: request to [HTTP::host], [HTTP::uri]"
if {[HTTP::uri] contains "/init/"]}{
log local0. "[IP::client_addr]:[TCP::client_port]: URI contained /init/, dropped request"
discard
}
}
when HTTP_REQUEST {
log local0. "[IP::client_addr]:[TCP::client_port]: -------------------------------------"
log local0. "[IP::client_addr]:[TCP::client_port]: \$::cm2prod_filtered_URI contents: $::cm2prod_filtered_URI"
log local0. "[IP::client_addr]:[TCP::client_port]: \$::corporate_external_net contents: $::corporate_external_net"
log local0. "[IP::client_addr]:[TCP::client_port]: request to [HTTP::host], [HTTP::uri]"
if {([matchclass [HTTP::uri] contains $::cm2prod_filtered_URI])}{
log local0. "[IP::client_addr]:[TCP::client_port]: matched URI to class
if {(not [matchclass [IP::client_addr] equals $::corporate_external_net])}{
log local0. "[IP::client_addr]:[TCP::client_port]: didn't match client to external networks class
discard
}
}
}
If the application is not case sensitive, you should set the output from [HTTP::uri] to lower case using [string tolower [HTTP::uri]].
The log output will be written to /var/log/ltm by default. You can run 'tail -f /var/log/ltm' from the command line to watch the output as you test. Hit Ctrl+c to stop the tail.
Aaron
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