Forum Discussion

Habib_Ulla_Khan's avatar
Habib_Ulla_Khan
Icon for Nimbostratus rankNimbostratus
Sep 27, 2017

Logs triggering due to irule

Hi All,

 

I am getting continues logs for as mentioned below. The irule for which i am getting alerts is below. Looking for more information from experts in devcentral

 

TCL error: /Common/True-Client-IP_or_X-Forwarded-For - Operation not supported (line 14) invoked from within "HTTP::header insert X-Forwarded-For [IP::client_addr]"

 

Code
when HTTP_REQUEST {
        if {[HTTP::header exists True-Client-IP]}{
                    if {[HTTP::header exists X-Forwarded-For]}{
                                HTTP::header remove X-Forwarded-For
                                HTTP::header insert X-Forwarded-For [HTTP::header True-Client-IP]      
                    } else {  
                    HTTP::header insert X-Forwarded-For [HTTP::header True-Client-IP]      
                    }
        }
        else {
                    if {[HTTP::header exists X-Forwarded-For]}{
                                HTTP::header remove X-Forwarded-For
                                HTTP::header insert X-Forwarded-For [IP::client_addr]
                    } else {  
                    HTTP::header insert X-Forwarded-For [IP::client_addr]
                    }           
        }

}

 

2 Replies

  • You're missing a closing brace "}" I've added it to the last line: I've also moved the 'else' in the first 'if' to be between the close and open braces as TCL sometimes complains about it

    when HTTP_REQUEST {
            if {[HTTP::header exists True-Client-IP]}{
                        if {[HTTP::header exists X-Forwarded-For]}{
                                    HTTP::header remove X-Forwarded-For
                                    HTTP::header insert X-Forwarded-For [HTTP::header True-Client-IP]      
                        } else {  
                        HTTP::header insert X-Forwarded-For [HTTP::header True-Client-IP]      
                        }
            } else {
                        if {[HTTP::header exists X-Forwarded-For]}{
                                    HTTP::header remove X-Forwarded-For
                                    HTTP::header insert X-Forwarded-For [IP::client_addr]
                        } else {  
                        HTTP::header insert X-Forwarded-For [IP::client_addr]
                        }           
            }
    }  
    
  • Hi,

     

    this error is not an irule format error but may be the consequence of a redirect on another irule evaluated before.

     

    if you have 2 irules assigned to the same VS:

     

    • irule 1 : execute a redirect
    • irule 2 : change HTTP request headers or execute another redirect

    then, the second irule will raise the same error you posted because the first irule redirect invalidate any other HTTP changes operations.