Error with a HTTP redirect iRule HTTP::redirect "${proto}://$NewHost[HTTP::uri]
I am running the following iRule below and am getting an error that multiple redirects are not supported. Do you know why this error is occurring ? I have looked through the forums and have tried some of the solutions but they do not fix the logic below. it is this line HTTP::redirect "${proto}://$NewHost[HTTP::uri]" which is causing the error.
Sep 26 14:06:50 testmachine err tmm[13272]: 01220001:3: TCL error: /Common/jimtestsso - Operation not supported. Multiple redirect/respond invocations not allowed (line 1) invoked from within "HTTP::redirect "${proto}://$NewHost[HTTP::uri]""
iRule when CLIENT_ACCEPTED { Set a variable to track whether this is an HTTP or HTTPS request set proto "http" } when CLIENTSSL_HANDSHAKE { There was a client side SSL handshake, so update the variable to HTTPS set proto "https" } when HTTP_REQUEST { get host and set new host... set SourceHost [HTTP::host]
Change these below to configure the iRule settings.
NewHost is the hostmane that the redirection will be to, if required
set NewHost "www.example.com:445"
ViaHeaderCheckList is the list of strings to search for in the Via Header, this is a tcl list-- which is space delimited.
set ViaHeaderCheckList {www.example.com}
set to 1 to log to /var/log/ltm
set debug 0
Do not Change below
check to see if the Via header is missing, if so, redirect.
if {![HTTP::header exists "Via"]} {
if {$debug} { log local0.error "Header missing, redirecting" }
Via Header is missing, redirect.
HTTP::redirect "${proto}://$NewHost[HTTP::uri]"
}
else
{
init Via header values into "Via"
set Via [HTTP::header values "Via"]
setup a variable to flag if a redirect needs to happen or not
set Redirect 0
loop through Via values, searching to the values in "ViaHeaderChecklist"
foreach domain $ViaHeaderCheckList {
if {$debug} { log local0.error "In loop Redirect = $Redirect"}
if {[string tolower $Via] contains $domain} {
if {$debug} { log local0.error "Incrementing $Redirect"}
incr Redirect
}
}
Do the redirect if no match was found
if { ($Redirect < 1) } {
if {$debug} { log local0.error "Redirecting"}
HTTP::redirect "${proto}://$NewHost[HTTP::uri]"
}
}
}