Forum Discussion
Torsten_Heß_937
Nimbostratus
May 03, 2005Matchclass HTTP::HOST
Hello,
I have problem concerning the following rule. I tried to migrate a 4.x rule to a 9.5 rule an it failed. The rule is accepted but didn´t work.
The 4.x rule looks like:
if ...
Colin_Walker_12
May 18, 2005Historic F5 Account
First of all, without further information as to how things are actually behaving and failing, I can't be certain of the cause of the problem.
However, it appears as though you're using a matchclass statement when attempting to match only part of a string. As has been discussed, the matchclass function will match against an exact string. To search for only part of a string, you’ll want to use “contains”, instead of “equals” in conjunction with the matchclass function.
In your example, you define this class:
class test-DE-Domain {
"www.test"
"www.test1"
}
And then search for the host like this:
if { [matchclass [HTTP::host] equals $::test-DE-Domain] } {
What this is saying, is that if the host is exactly "www.test" or "www.test1", it will match. This does not account for a domain extension. So, while "www.test" matches, "www.test.com" does not. This holds true for any extension added to "www.test" or "www.test1" to make them viable, fully qualified domain names.
So, unless you're using custom hosts files to eliminate the need for the domain extensions, your rule will likely not function, as it won't match the HTTP:host since the host will actually be something to the effect of "www.test.com" or "www.test1.co.uk", depending on the domain extension.
Try replacing “equals” with “contains” in your if statement, and see if you get better results.
So, the modified rule would look something like this :
when HTTP_REQUEST {
if { [matchclass [HTTP::host] contains $:: test-DE-Domain] } {
pool Test-Pool
log "[HTTP::uri]"
} else {
log "Failed"
}
}
I'd be happy to take another look with some more info if this doesn't answer your questions.
-CW
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
