Forum Discussion

Michael_Sloan's avatar
Michael_Sloan
Icon for Nimbostratus rankNimbostratus
Jun 11, 2019

HTTP::header TCL errors

We have multiple HA pairs of F5 VMs in production running BigIP 12.1.3 and we have some quirky issues with iRules most commonly when using HTTP::header and I'd like some help if anyone has insight on the issue.

 

This works on one production pair:

 

when HTTP_REQUEST {

   STREAM::disable

   HTTP::header remove "Accept-Encoding"

}

when HTTP_RESPONSE {

   STREAM::disable

   if { [HTTP::header is_redirect] } {

      HTTP::header replace Location [string map -nocase {http://my.example2-test.com/ https://my.example2-test.com/} [HTTP::header value Location]]

      HTTP::header replace Location [string map -nocase {http://my.example2.com/ https://my.example2.com/} [HTTP::header value Location]]

   }

 

   if {[HTTP::header value Content-Type] contains "text"} {

      STREAM::expression {@http://my.example2.com/@https://my.example2.com/@ @http://my.example2.com/@https://my.example2.com/@}

      STREAM::enable

   }

}

 

But this, which is identical aside from the hostname, does not work on another production pair:

 

when HTTP_REQUEST {

  STREAM::disable

  HTTP::header remove "Accept-Encoding"

}

when HTTP_RESPONSE {

   STREAM::disable

   if { [HTTP::header is_redirect] } {

      HTTP::header replace Location [string map -nocase {http://my.example.com/ https://my.example.com/} [HTTP::header value Location]]

   }

 

   if {[HTTP::header value Content-Type] contains "text"} {

      STREAM::expression {@http://my.example.com/@https://my.example.com/@}

      STREAM::enable

   }

}

 

Both have HTTP and stream profiles attached to the virtual server, but the failing one produces the following TCL error in the logs:

 

F5   tmm3[10375]   01220001   TCL error: /Common/rewrite-my.example.com-https <HTTP_REQUEST> - Operation not supported (line 1) invoked from within "HTTP::header remove "Accept-Encoding""

 

I have another iRule using HTTP::header that also throws TCL errors that makes no sense, as I've tried pretty much every variation on parameters (variables, with quotes, without quotes):

 

when HTTP_REQUEST {

   set client_port [TCP::client_port]

   if {!([HTTP::header exists "X-Forwarded-Port"])} {

     HTTP::header insert "X-Forwarded-Port" $client_port

   }

}

 

But it throws this error consistently:

 

TCL error: /Common/x-forwarded-port <HTTP_REQUEST> - Operation not supported (line 3) invoked from within "HTTP::header insert "X-Forwarded-Port" $client_port"

 

Can anyone shed light on why this happens? To make matters more confusing, the working iRule is on pair A, the duplicate broken iRule is on pair B, and the broken insert iRule is on pair A.

1 Reply

  • Do you have more than one iRule or Local Traffic Policy including the ones noted added to your virtual server? I'm wondering if other iRules may have already manipulated the traffic in a way that might cause this behavior.

     

    As one example if a redirect occurs for a request in a previous rule/policy then the header remove command is triggered it could cause an error like what you experienced.