Forum Discussion

f5beginner's avatar
f5beginner
Icon for Cirrostratus rankCirrostratus
Jun 24, 2019

Error logs TCL script HTTP:host

Hello, I´m using this irule:

when HTTP_REQUEST {
# Check if the host starts with www.
if {[string tolower [HTTP::host]] starts_with "www."}{
# Redirect with the www. prefix removed to the same URI
HTTP::redirect "http://[string range [HTTP::host] 4 end][HTTP::uri]"
   }
} 

And it works, but I receiving error logs on my F5:

TCL error: /Common/Remove_WWW <HTTP_REQUEST> - ERR_NOT_SUPPORTED (line 2) invoked from within "HTTP::host"

Do someone know, what could be a problem ?

Above mentioned tcl script is from this site: https://devcentral.f5.com/s/question/0D51T00006i7XsO/multiple-ssl-cert-on-1-vip-question

Thank you

7 Replies

  • Your iRule works without any problem on my lab BIG-IP. I don't see any error messages in the /var/log/ltm file. I'm using 14.1.0.3. You could try removing the comments in the iRule. I've seen comments in the iRule being responsible for error messages.

    # curl -v http://10.23.98.218 -H "host: www.example.com"
    * Rebuilt URL to: http://10.23.98.218/
    *   Trying 10.23.98.218...
    * Connected to 10.23.98.218 (10.23.98.218) port 80 (#0)
    > GET / HTTP/1.1
    > User-Agent: curl/7.40.0
    > Accept: */*
    > host: www.example.com
    >
    * HTTP 1.0, assume close after body
    < HTTP/1.0 302 Moved Temporarily
    < Location: http://example.com/
    < Server: BigIP
    * HTTP/1.0 connection set to keep alive!
    < Connection: Keep-Alive
    < Content-Length: 0
    <
    * Connection #0 to host 10.23.98.218 left intact
    #
  • Hi F5beginner,

     

    Did you attached more than one iRule to the same Virtual Server and one of the iRule processed earlier did already responded the ongoing HTTP request?

     

    Cheers, Kai

     

     

     

     

  • Hi Guys,

     

    @Niels van Sluis, thank you for answer, I have deleted comments, but it does not help.

    @Kai Wilke, thanks for answer, for virtual server there is used one irule, but in policies there I have defined another tcl rules: Redirect to location 'tcl:https://[getfield [HTTP::host] : 1][HTTP::uri]' at request time, so I guess, this could be reason of error logs, is there any way to change priority of irule ?

     

    Thank you

     

     

  • Hi F5beginner,

    the chances are high that the redirect in your LTM Policy is interfering with the subsequent iRule execution. Keep in mind that the LTM Policies are processed always first and you cant change the priority so that the iRule will be processed before LTM Policies.

    As an easy fix you may want to wrap your iRule logic into a catch { } command to supress the TCL error whenenver the iRule is unable to execute the redirect.

    when HTTP_REQUEST {
    	catch {
    		# Check if the host starts with www.
    		if {[string tolower [HTTP::host]] starts_with "www."}{
    			# Redirect with the www. prefix removed to the same URI
    			HTTP::redirect "http://[string range [HTTP::host] 4 end][HTTP::uri]"
    		}
    	}
    } 

    A slightly more complex (but cleaner) fix, would be to migrate your tasks so that they would either use LTM Policies or iRule but not both at the same time...

    Cheers, Kai

    • Kai_Wilke's avatar
      Kai_Wilke
      Icon for MVP rankMVP

      Hi Darius,

       

      and the command used before v14 was [catch {HTTP::payload replace 0 0 {}}].

       

      Note: Catching slightly unstable code blocks is most of the time more effective (easier to implement and also less overhead) than implementing extensive error checks... ;-)

       

      Cheers, Kai