Forum Discussion
iRule Errors when upgrading to v14.1
All -
We just upgraded our F5 LTM to v14.1 from v11.6.3 successfully. However, now that we are running on v14.1, we are getting a lot of iRule errors in our LTM Logs.
I have edited the iRule names & paths of URLs & URIs for security purposes.
Any help with these iRule changes would be greatly appreciated.
Examples of the errors are:
TCL error: /Common/iRule_1 - ERR_NOT_SUPPORTED (line 2) invoked from within "HTTP::header "User-Agent""
The iRule has the following:
when HTTP_REQUEST {
Rewrite the User-Agent header value if it's empty
if { [string length [HTTP::header "User-Agent"]] == 0 || not [HTTP::header exists "User-Agent"] }{
Replace the User-Agent header with a default value
HTTP::header replace "User-Agent" "Mozilla/4.0 (compatible; No User Agent Provided)"
}
}
Another Example error:
TCL error: /Common/redirect_irule - ERR_NOT_SUPPORTED (line 1) invoked from within "HTTP::uri"
TCL error: /Common/redirect_irule - ERR_NOT_SUPPORTED (line 7) invoked from within "HTTP::uri"
The iRule has the following:
when HTTP_REQUEST {
if { [HTTP::uri] equals "/portal/" or [HTTP::uri] equals "/"} {
if {[HTTP::host] starts_with "URL"}{
HTTP::redirect "http://www.URL.org/contact-us/contact-us.aspx"}
if {[HTTP::host] starts_with "path"}{
HTTP::redirect "http://www.anotherURL.com/Contact-Us/Contact-Us.aspx"}
if {[HTTP::host] starts_with "path1"}{
HTTP::redirect "http://www.anotherURL.com/applications/path1/contact-us.aspx"}
if {[HTTP::host] starts_with "path2"}{
HTTP::redirect "http://www.anotherURL.com/applications/path2/Contact-us.aspx"}
if {[HTTP::host] starts_with "path3"}{
HTTP::redirect "http://www.anthoerURL.com/applications/path3/contact-us.aspx"}
}
}
For us a solution has been to add "elseif" or "return" statements to each iRule that has a issue. So far the change to add the "elseif" between each "if" statement appears to now work properly.
Hopefully if someone else has this same issue when upgrading their F5 to v14.1+ this will help them.
when HTTP_REQUEST { if {[HTTP::has_responded]} {return} Rewrite the User-Agent header value if it's empty if { [string length [HTTP::header "User-Agent"]] == 0 || not [HTTP::header exists "User- Agent"] }{ Replace the User-Agent header with a default value HTTP::header replace "User-Agent" "Mozilla/4.0 (compatible; No User Agent Provided)" } } `
or
`when HTTP_REQUEST { if {[HTTP::has_responded]} {return} if { [HTTP::uri] equals "/portal/" or [HTTP::uri] equals "/"} { if {[HTTP::host] starts_with "URL"}{ HTTP::redirect "http://www.URL.org/contact-us/contact-us.aspx"} elseif {[HTTP::host] starts_with "path"}{ HTTP::redirect "http://www.anotherURL.com/Contact-Us/Contact-Us.aspx"} elseif {[HTTP::host] starts_with "path1"}{ HTTP::redirect "http://www.anotherURL.com/applications/path1/contact-us.aspx"} elseif {[HTTP::host] starts_with "path2"}{ HTTP::redirect "http://www.anotherURL.com/applications/path2/Contact-us.aspx"} elseif {[HTTP::host] starts_with "path3"}{ HTTP::redirect "http://www.anthoerURL.com/applications/path3/contact-us.aspx"} } }
- Andy_McGrath
Cumulonimbus
Your first iRule is the
command think you need to include the key wordHTTP::header
in 14.value
when HTTP_REQUEST { Rewrite the User-Agent header value if it's empty if {([string length [HTTP::header value "User-Agent"]] == 0) || !([HTTP::header exists "User-Agent"])}{ Replace the User-Agent header with a default value HTTP::header replace "User-Agent" "Mozilla/4.0 (compatible; No User Agent Provided)" } }
With your second iRule looks ok other than the formatting and the perfect use case for using
, give the following a try and see if this fixes the errors:switch
when HTTP_REQUEST { if {([HTTP::uri] eq "/portal/") || ([HTTP::uri] eq "/")} { switch -glob [HTTP::host] { "URL*" {HTTP::redirect "http://www.URL.org/contact-us/contact-us.aspx"} "path1*" {HTTP::redirect "http://www.anotherURL.com/applications/path1/contact-us.aspx"} "path2*" {HTTP::redirect "http://www.anotherURL.com/applications/path2/contact-us.aspx"} "path3*" {HTTP::redirect "http://www.anotherURL.com/applications/path3/contact-us.aspx"} "path*" {HTTP::redirect "http://www.anotherURL.com/Contact-Us/Contact-Us.aspx"} } } }
- Sam_Hall
Nimbostratus
I had a similar issue on 14.1. I've figured out what behaviour has changed and what can be done to work around this.
My virtual server has two iRules, the 1st iRule has some header cleansing logic using "HTTP::header replace" this iRule has higher priority, it runs first. My second irule had some logic that sometimes triggers a HTTP response, similar to what you have above. HTTP::redirect triggers a HTTP response so the issue is probably the same.
It appears that you can no longer modify HTTP request headers if you trigger a response at the F5. You need to rejig your code so that "HTTP::header replace" only occurs after any possible HTTP responses have been triggered (and these should be followed by a "return" to stop processing the request).
- Sam_Hall
Nimbostratus
Ignore me, I just realised the second iRule had no "priority", so it was actually occuring before the 1st iRule. Added the priority and that fixed it.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com