Forum Discussion
Roflcopter
Nimbostratus
Feb 12, 2018Content-Security-Policy
I am trying to construct and iRule that will put a variable into a HTTP Header.
The requirements are -
When a client connects set their HTTP:host as a variable for later use Check that the HTTP...
oguzy
Cirrostratus
Feb 12, 2018Hi,
The code stated below may work. Can you try it?
when CLIENT_ACCEPTED {
set host_exist 0
}
when HTTP_REQUEST {
set host [HTTP::host]
if { [class match $host contains host_lookup_table] } {
set host_exist 1
}
}
when HTTP_RESPONSE {
if { $host_exist equals 1 } {
HTTP::header insert "X-Content-Security-Policy" "frame-ancestors 'self' $host"
HTTP::header insert "X-Content-Security-Policy" "frame-scr 'self' '$host'"
}
else {
HTTP::header insert "X-Content-Security-Policy" "frame-ancestors 'self'"
HTTP::header insert "X-Content-Security-Policy" "frame-scr 'self'"
}
}
Roflcopter
Nimbostratus
Feb 12, 2018Thanks a lot. Looks like it would work, I like the way you used a second variable that can be used when making the decision on what to send back to the client, so nice and simple!
I'll give it a test run tomorrow, thanks for taking the time to post a response!
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects