I’ve tested this and it works fine, but for some folks its errors.. in IE, is give them a 404 and in Firefox, it’s complaining of a “Connection Reset”.
I can’t see anything as to why this would be caused.
if { [regexp {www} [HTTP::host]] } {
scan [HTTP::host] {%[^.].%[^.].%s} www host dom
} else {
scan [HTTP::host] {%[^.].%s} host dom
}
if { not [regexp {domain|www|wsecure|ssl} $host] } {
log local0. “Caught a MS host $host, redirecting…”
If you’re seeing connection resets with an iRule, check the /var/log/ltm file for runtime TCL errors.
However, as Nitass said, you should be able to rework this iRule with string pattern matching to avoid the high CPU costs of regexes. I’m not exactly sure what logic you’re trying to implement, but here’s a stab at it:
when HTTP_REQUEST {
Remove www. from the host header value if it is present
set host [string map {www. ""} [string tolower [HTTP::host]]]
log local0. "[IP::client_addr]:[TCP::client_port]: Parsed $host from [HTTP::host]"
switch $host {
"domain" -
"wsecure" -
"ssl" {
log local0. "[IP::client_addr]:[TCP::client_port]: Matched part of $host, redirecting"
HTTP::redirect "https://www.domain.com/MS/RedirectMS?site=hub&value=$host"
}
}
}
Thanks for the replies. I do think an error in other parts of the rule was the issue. I have taken your advice though to reduce my use of regexp. Is there a point at which the number of elements in a switch statement starts to be of concern?
There are varying suggestions on it, but IMO (as you will see on a benchmark 100K connect test) while there is a performance difference, unless you are seriously pinching CPU cycles you should go with which ever is easiest for you to maintain (but be aware of the caveats of each like the ones that Arie noticed in smp’s post).