Anush
Aug 11, 2016Nimbostratus
TCL errors
we have following irule configured and it's throwing large amount of TCL errors evenif logging is disable for the irule. It's working ok and in production but not sure why it cause TCL errors
...
The syntax for a class match -value is:
class match -value
This means "retrieve the value associated with the key in the data group named ". In your case, the Host header is "google", so in your code, once HTTP::host expands, you are trying to do this:
class match -value [HTTP::uri] equals VURL_google
but there is no data group named "VURL_google". I suspect you're confusing the use of equals here, which is actually a parameter of class, rather than the normal equals operator. I believe you are trying to lookup the value in a data group that is associated with the key HTTP::uri, then see if that value matches the literal "VURL_google". If I'm right, then let's assume your URI->host matching data group is called dg-uri-host. Your code would be:
when HTTP_REQUEST {
set redirect_url [class lookup [string tolower [HTTP::uri]] dg-uri-host]
HTTP::redirect $redirect_url
}
If you were trying to make this conditional, then it would be:
when HTTP_REQUEST {
set redirect_url [class lookup [string tolower [HTTP::uri]] dg-uri-host]
if { $redirect_url eq "VURL_google" } {
HTTP::redirect $redirect_url
}
}
Note that this:
class lookup
is synonymous with this:
class match -value equals
Also note that HTTP::uri is the entire query-uri, which means that, if a client submitted this:
GET /foo/bar/baz.html?this=that&here=there
then HTTP::uri would be "/foo/bar/baz.html?this=that&here=there". You might find the use of HTTP::path more fruitful. Also, while your filesystem may or may not be case-sensitive, the Request-URI path is in fact case-sensitive, so normalizing the case (that is, using string tolower) on the Request-URI or Request-URI path is -- strictly speaking -- not needed and in fact causes differing paths to appear to be equal.
Thanks Vernon for your details analysis on this. I think, posted TCL errors only for Google.com made confusion here. I have hundreds of TCL errors for different sites in logs, all are due to not find match class. so what I am looking for here is, how to prevent these errors? all your recommendations are excellent and very useful but I think evenif I use those, I may end up with similar TCL errors if request don't find match class or may be I don't understand correctly.
Thanks again for your time.