Forum Discussion
Way to replace HTTP header being applied by APM portals
All full webtop portals I create have this HTTP header, which I need to override. Using iRules for this is failing.
Header in question:
Content-Security-Policy: default-src 'self' 'unsafe-inline' 'unsafe-eval' ws: wss: jar: data:;
I need to modify it to include "connect-src *"
Here's my iRule:
when HTTP_RESPONSE {
set cspstring "default-src 'self' 'unsafe-inline' 'unsafe-eval' ws: wss: jar: data:; connect-src *" HTTP::header replace Content-Security-Policy $cspstring}`
The header is never replaced on the VS's I apply this to. I can manipulate any other header, but this one seems to be permanent for some reason.
Any help much appreciated! Michael
5 Replies
- mapennell_21218
Nimbostratus
I'm pretty convinced there's something preventing me from modifying the CSP header out of the F5. I can't find this referenced in any documentation. Definitely could use some help... - Jon_Bartlett_10Historic F5 Account
What happens if you try removing the header instead of a replace? What version of TMOS are you running?
when HTTP_RESPONSE_RELEASE {
foreach header {Content-Security-Policy} {
log local0. "Removing $header: [HTTP::header value $header]"
HTTP::header remove $header
}
}- Abed_AL-R
Cirrostratus
Hi Jon Bartlett
I came across this issue today , LTM/APM 12.1.3
I used this iRule you mentioned and it solved the problem in chrome
In IE edge or 10 the problem still happening
The thing with IE is that it does not showing the error message , it is just freezing
I tried even replacing the irule with this one :
when HTTP_RESPONSE_RELEASE { foreach header {X-Content-Security-Policy} { log local0. "Removing $header: [HTTP::header value $header]" HTTP::header remove $header } }Didn't help..
If I try to open the web-application internally , without APM , it is working fine with all browsers
What could be done here?
- Kevin_Stewart
Employee
The CSP header value is actually coming from APM, so there's no local response event that can catch that. The best option would be to put a VIP targeting solution in front of your APM VIP. The external VIP would be able to see and manipulate the internal APM's responses. You'd put your client SSL handling on the external VIP and the internal APM VIP would listen on HTTP. Here's what that external iRule might look like:
when CLIENT_ACCEPTED { virtual internal-vip } when HTTP_RESPONSE { if { [HTTP::header exists Content-Security-Policy] } { HTTP::header replace Content-Security-Policy [string map {";" " connect-src *;"} [HTTP::header Content-Security-Policy]] } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com