Forum Discussion
yves_werniers_1
Nimbostratus
Oct 14, 2009class and v9.1.2
Hello,
It seems like the class command was introduced in v10.0, whereas matchclass was introduced in v9.0.
I am running v9.1.2. How can I cerate something classlike and use classmatch?
I want to limit connections to certain url/uri combinations based on the source ip address. I am using the X-Forwarded-For header because it is behind a reverse proxy.
This is the script I would like to use:
class hrmstest_uris {
"/hraccent/ess/client_prod"
"/hraccent/ess/login.php?company=client_prod"
"/hraccentops/ess/client_prod"
"/hraccentops/ess/login.php?company=client_prod"
}
when HTTP_REQUEST {
set my_uri [string tolower [HTTP::uri]]
if {[HTTP::host] == "www.host.com" and [matchclass $my_uri starts_with $::hrmstest_uris] } {
if { [HTTP::header X-Forwarded-For] != "ip1" and [HTTP::header X-Forwarded-For] != "ip2" and [HTTP::header X-Forwarded-For] != "ip3"}{
log local0. "\[request blocked\] : [HTTP::header X-Forwarded-For]"
drop
}
}
}
- hoolio
Cirrostratus
You can use matchclass in 9.x or 10.x to evaluate an IP address or string against a class. - yves_werniers_1
Nimbostratus
but the big problem is that I cannot even save that iRule. I get an error on the class line: - hoolio
Cirrostratus
Ah, the class definition is separate from the iRule. You define the class (called a datagroup in the GUI) under Local Traffic | iRules | Datagroup List. Then define the iRule under the iRules tab. - yves_werniers_1
Nimbostratus
yes! That's what I was missing.
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