Bryan_38320
Jul 16, 2010Nimbostratus
class match instead of findclass
I recently did an upgrade from 9.x to 10.1. Under 9.x we were using a class data structure for several hundred redirects.
Example:
class noclass {
"/notthissite1 http://www.thissite1.com/"
"/notthissite2 http://www.thissite2.com/"
"/notthissite3 http://www.thissite3.com/"
}
rule classyrule {
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
set gohere [findclass $uri $::noclass " "]
if { $gohere ne "" } {
HTTP::redirect $gohere
}
}
}
In 10.1 that changed slightly, a few extra brackets in the class, but more importantly, the findclass command has a huge performance issue when multiple tmm are running. F5 says to use "class match" instead of findclass to fix that. After some research, it appears that this SHOULD work (but does not):
class noclass {
{
"/notthissite1 http://www.thissite1.com/"
"/notthissite2 http://www.thissite2.com/"
"/notthissite3 http://www.thissite3.com/"
}
}
rule classyrule {
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
set gohere [class match -value $uri equals noclass]
if { $gohere ne "" } {
HTTP::redirect $gohere
}
}
}
After some digging and adding some extra logs (removed for brevity) $gohere returns nothing and no redirect happens. Even if it did, the appropriate value isn't there to be redirected to.
I also looked into the format of the class. There appear to be several methods of defining the class. None of my efforts have been successful.
The most popular way seems to be something like this:
class noclass {
{
"/notthissite1" { "http://www.thissite1.com/" }
"/notthissite2" { "http://www.thissite2.com/" }
"/notthissite3" { "http://www.thissite3.com/" }
}
}
This behaves exactly the same way... $gohere does not return the value from the class.
I also tried an external file:
my file is noclass.class:
"/notthissite1" := "http://www.thissite1.com/",
"/notthissite2" := "http://www.thissite2.com/",
"/notthissite3" := "http://www.thissite3.com/",
bigip.conf:
class noclass {
type string
filename /config/noclass.class
}
rule classyrule {
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
set gohere [class match -value $uri equals noclass]
if { $gohere ne "" } {
HTTP::redirect $gohere
}
}
}
This one chokes on line 2 (I've tried several iterations of this as well, but above is my interpretation of the documentation).
I don't really care if it is an internal or external class, external might be a nice way to clean the config up a bit, I'm more concerned about getting the value back from my class lookup. I'm apparently going about something all wrong.
I thank you all for any constructive comments.