For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Anthony's avatar
Anthony
Icon for Nimbostratus rankNimbostratus
Sep 27, 2019
Solved

TCL error on simple replace header iRule

I'm getting a TCL error from a very simple iRule and cannot understand what scenario would cause it to fail.

The iRule does a simple port removal from the host header.

when HTTP_REQUEST
{
   if { [HTTP::host] contains ":" }
   {
      log local0. "[HTTP::host] becomes [substr [HTTP::host] 0 ":"]"
      HTTP::header replace Host "[substr [HTTP::host] 0 ":"]"
   }
}

Sep 27 12:20:19 LTM1 info tmm3[22524]: Rule /Common/remove_port <HTTP_REQUEST>: www.domain.com:443 becomes www.domain.com
Sep 27 12:20:19 LTM1 err tmm3[22524]: 01220001:3: TCL error: /Common/remove_port <HTTP_REQUEST> - Operation not supported (line 4)     invoked fro
m within "HTTP::header replace Host "[substr [HTTP::host] 0 ":"]""


Any ideas on what scenario would cause this to happen? It works on most, just seems there is something particular that causes the error to be thrown.

Many thanks

Anthony

  • Dario_Garrido's avatar
    Dario_Garrido
    Oct 04, 2019

    Try this.

    when HTTP_REQUEST {
       if { [HTTP::host] contains ":" } {
          log local0. "[HTTP::host] becomes [getfield [HTTP::host] {:} 1]"
          HTTP::header replace Host [getfield [HTTP::host] {:} 1]
       }
    }

    KR,

    Dario.

8 Replies

  • What version are you running? Also, how were you testing? I just loaded that irule on a 14.1 box and I sent traffic through without a problem.

    However, I couldn't get it to log an HTTP::host with the colon in it. I created a line to only log HTTP::host and it only puts the domain name, not the colon.

    So, just curious which client you're using to test.

  • Hello Anthony.

    That's a common issue with HTTP::header command when you use it with quotes. Just do this to avoid the error

    set new_header "[substr [HTTP::host] 0 ":"]"
    HTTP::header replace Host $new_header

    KR,

    Dario.

  • We're running v12.1.4. It only happens every so often so I don't actually know what is causing it. I did wonder if it was something to do with the string replacement. I prefersetting a varaible before the replacement so I'll do that and see if it stops it.

     

    Thanks for your answers.

      • Anthony's avatar
        Anthony
        Icon for Nimbostratus rankNimbostratus

        Quick answer is that its generated the same error.

        TCL error: /Common/remove_port <HTTP_REQUEST> - Operation not supported (line 4)     invoked from within "HTTP::header replace Host $new_host"

        Back to the drawing board...