Forum Discussion

michaelw3's avatar
michaelw3
Icon for Nimbostratus rankNimbostratus
Feb 26, 2018

irule error x-content-type-options

I am trying to create the following irule but keep getting error message.

when HTTP_RESPONSE { if {!([HTTP::header exists "X-Content-Type-Options" ])} { HTTP::header insert "X-Content-Type-Options" "'nosniff'" }

Error message below

x-content-type-options Definition 01070151:3: Rule [/Common/x-content-type-options] error: /Common/x-content-type-options:1: error: [parse error: missing close-brace][{ if {!([HTTP::header exists "X-Content-Type-Options" ])} { HTTP::header insert "X-Content-Type-Options" "'nosniff'" }] /Common/x-content-type-options:2: error: [command is not valid in the current scope][if {!([HTTP::header exists "X-Content-Type-Options" ])} { HTTP::header insert "X-Content-Type-Options" "'nosniff'" }]

1 Reply

  • Make sure you include the close bracket at the end:

    when HTTP_RESPONSE { 
        if {!([HTTP::header exists "X-Content-Type-Options"])} { 
            HTTP::header insert "X-Content-Type-Options" "nosniff" 
        }
    }