Forum Discussion

Bhavik_1402's avatar
Bhavik_1402
Icon for Nimbostratus rankNimbostratus
Apr 30, 2021

irule syntax error

Hi Folks,

 

I'm new to iRules and need to create few irules which is provided by the application vendor and getting an error for one of the line as shown below in italic bold letter. The syntax starts with "for=" and LTM is giving below error.

 

01070151:3: Rule [/Common/iRule_Single_VIP] error: /Common/iRule_Single_VIP:58: error: [undefined procedure: for=]["for="[IP::client_addr]";]

/Common/iRule_Single_VIP:58: error: [undefined procedure: TCP::local_host][TCP::local_host]

 

if { not [HTTP::header exists "x-forwarded-for" ] } {

HTTP::header insert "X-Forwarded-For" [getfield [IP::client_addr] "%" 1]

}

### HTTP::header replace "X-Forwarded-For" [getfield [IP::client_addr] "%" 1]

HTTP::header replace "Host" [HTTP::host]

HTTP::header insert "X-Forwarded-Host" [HTTP::host]

HTTP::header insert "X-Forwarded-Hostname" [getfield [HTTP::host] ":" 1]

## Check to see that an upstream proxy has not already inserted

## the X-Forwarded-Port header, if not insert with current local

## port being used

if { not [HTTP::header exists "x-forwarded-port" ] } {

HTTP::header insert "X-Forwarded-Port" [TCP::local_port]

}

HTTP::header insert "X-Forwarded-ContextPath" /$dsServiceName

HTTP::header insert "X-Forwarded-Proto" "https"

# Create the Forward header to be compliant with RFC7239

# set string

"for="[IP::client_addr]";proto="$proto";by="[TCP::local_host]";host="[HTTP::host]";contextpath="$dsServiceName

# HTTP::header insert "Forwarded" string

## For each response which was a CORS request add the CORS

## headers to allow potential in page content to access

## information from this service

##

## F5 will be creating for the client. This allows the

## application to have the information even on the initial

## request

##

}

 

Can someone guide please?

  • Hi Bhavik_1402,

    # char is placed at the beginning of the comment lines. The line starting with "for" should be at the end of the line above.

    # Create the Forward header to be compliant with RFC7239
    # set string "for=[IP::client_addr];proto=$proto;by=[TCP::local_host];host=[HTTP::host];contextpath=$dsServiceName"
    # HTTP::header insert "Forwarded" string
    • Bhavik_1402's avatar
      Bhavik_1402
      Icon for Nimbostratus rankNimbostratus

      # means its just for comment and will not take in the effect. so does it mean the entire line is only for comment and will not be processed in irule?

       

      # set string "for=[IP::client_addr];proto=$proto;by=[TCP::local_host];host=[HTTP::host] contextpath=$dsServiceName"

      ?