I have built this iRule to simulate the “Redirect_Rewrite modify” option.
when HTTP_REQUEST {
Save the host
set host [string tolower [HTTP::host]]
}
when HTTP_RESPONSE {
if {[HTTP::is_redirect] and [HTTP::header exists “location”]} {
set location [string tolower [HTTP::header “location”]]
if { ($location starts_with “http://”) and ($location contains $host)} {
set newloc “https://[substr [HTTP::header Location] 7]”
HTTP::header replace Location $newloc
}
}
}
Works good in test, but when I put it in production, I am getting this error occasionally.
Mar 9 12:49:21 tmm tmm[1729]: 01220001:3: TCL error: redirect_to_https_matching - Illegal argument. Can’t execute in the current context. (line 1) invoked from within “HTTP::is_redirect”
Mar 9 14:38:33 tmm tmm[1729]: 01220001:3: TCL error: redirect_to_https_matching - Illegal argument. Can’t execute in the current context. (line 1) invoked from within “HTTP::status”
I added priority to my iRule, causing it to run first, and the errors seem to have disappeared. Wonder what was happening in the other iRules that was breaking this? Any ideas?
The current iRule is:
when HTTP_REQUEST priority 100 {
Save the host
set host [string tolower [HTTP::host]]
}
when HTTP_RESPONSE priority 100 {
if {[HTTP::is_redirect]} {
set location [string tolower [HTTP::header “Location”]]
if { ($location starts_with “http://”) and ($location contains $host)} {
I have a problem with 9.4.6 and came across this thread, I have noticed this after upgrading to 9.4.6.
May 3 19:13:42 tmm tmm[2269]: 01220001:3: TCL error: ir_irule1 - Illegal argument. Can’t execute in the current context. (line 39) invoked from within “HTTP::respond 401”