cancel
Showing results for 
Search instead for 
Did you mean: 
Login & Join the DevCentral Connects Group to watch the Recorded LiveStream (May 12) on Basic iControl Security - show notes included.

iRule to Remove Duplicate Header by Value

spars
Altostratus
Altostratus

Via iRule, trying to remove duplicate Strict-Transport-Security headers (developers are unable to), the below code does not seem to work.

 

when HTTP_REQUEST {     foreach a_header [HTTP::header "Strict-Transport-Security"] {      if {[HTTP::header $a_header] eq "max-age=2592000"}{        HTTP::header remove $a_header    }   } }

 

The below seems to work but gets rid of Strict-Transport-Security as a whole, which I do not want to do:

 

when HTTP_RESPONSE {  foreach header {Strict-Transport-Security} {   HTTP::header remove "Strict-Transport-Security"   HTTP::header remove "max-age=2592000"   }  }

 

1 ACCEPTED SOLUTION

SanjayP
MVP
MVP

You can use something like below

 

when HTTP_RESPONSE { HTTP::header remove "Strict-Transport-Security" HTTP::header insert Strict-Transport-Security "max-age=2592000" }

 

View solution in original post

2 REPLIES 2

SanjayP
MVP
MVP

You can use something like below

 

when HTTP_RESPONSE { HTTP::header remove "Strict-Transport-Security" HTTP::header insert Strict-Transport-Security "max-age=2592000" }

 

spars
Altostratus
Altostratus

  Appreciate the assist, that worked. Thank you