Forum Discussion

balcee's avatar
balcee
Icon for Altocumulus rankAltocumulus
Nov 05, 2024

iRule for Content Security Policy

Hey Guys, hope everyone is well and having a good day.

 

I'm looking for some help with an iRule that allows me to enable Content Security Policy on a Virtual Server.

 

Whenever I apply the following, the website breaks (i.e. images don't load, formatting is skewed, etc):

 

         if {!([HTTP::header exists "Content-Security-Policy"])} {

             HTTP::header insert Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self'; font-src 'self'; img-src 'self'; frame-src 'self'; upgrade-insecure-requests"

 

I've attached the error that is thrown up by the web server when the above is applied. Based on the error, I was thinking of adding 'unsafe-inline' to my iRule in an attempt to relax the policy.

 

Does anyone have any experience of applying such a rule? I would be very grateful for any assistance.

 

Thank you

No RepliesBe the first to reply