Forum Discussion
Michael_Mangret
Nimbostratus
Aug 13, 2007Irule Error message
Can anyone tell me what might be wrong with my Irule? It seems to be working. I get the message Forbidden when I send a call with the header x-moz set, but I still get this error message in my log. ...
hoolio
Cirrostratus
Aug 13, 2007You're getting the TCL error because $host_pool isn't being set for every request--but is being referenced in every request.
This is your original rule, formatted for easier reading:
when HTTP_REQUEST {
if {[string tolower [HTTP::header x-moz:] ] contains "prefetch" } {
HTTP::respond 403 content "Forbidden"
} else {
set host_pool [findclass [HTTP::host] $::DSHostPoolMap " "]
}
if { $host_pool ne "" } {
pool $host_pool
}
}Note that on every request, the $host_pool condition is being checked. It's only being set if the x-moz header check is false.
You might want to move the $host_pool check into the else. Or you could check to see that the $host_pool variable is set and not blank using [info exists host_pool].
You should also consider specifying what you want to happen if the [HTTP::host] value is not found in the datagroup.
Here's an example:
when HTTP_REQUEST {
if {[string tolower [HTTP::header x-moz]] eq "prefetch" } {
HTTP::respond 403 content "Forbidden"
} else {
set host_pool [findclass [string tolower [HTTP::host]] $::DSHostPoolMap " "]
if { $host_pool ne "" } {
pool $host_pool
} else {
pool default_pool
}
}
}Aaron
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