Forum Discussion
bmeyer06_204838
Jun 02, 2015Nimbostratus
iRule - Header Replace Blacklist
I'm trying to the X-Frame-Options header replace for a website, however some of the pages on the site require that setting to NOT be set. So I'm trying to create a black list of pages and this is what I've come up with:
when HTTP_REQUEST {
set my_host_uri [HTTP::uri]
}
when HTTP_RESPONSE {
if {
(not ([string tolower $my_host_uri] contains "notThisSubfolder1")) &&
(not ([string tolower $my_host_uri] contains "notThisSubfolder2")) &&
(not ([string tolower $my_host_uri] contains "notThisSubfolder3"))
}
{
HTTP::header replace X-Frame-Options "SAMEORIGIN"
}
}
Should this work? Is there a better way to do this?
- Michael_JenkinsCirrostratus
I think this would work, though for performance sake I would do it a little differently (and your strings are mixed case when you're trying to compare on lowecase)...
when HTTP_REQUEST { set host [string tolower [HTTP::uri] } when HTTP_RESPONSE { switch -glob $host { "*notthissubfolder11*" - "*notthissubfolder12*" - "*notthissubfolder13*" { Do nothing } default { Replace the header value HTTP::header replace X-Frame-Options "SAMEORIGIN" } } }
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