Forum Discussion
404 irule with security headers
I am writting an irule to return a ifile (for a 404 error). In addition to returning the ifile (which does work) I want to insert security headers (this isnt working. How can I insert these headers
when HTTP_REQUEST { set host [HTTP::host] set path [HTTP::path] switch $path { "/PageNotFound" { HTTP::respond 200 content [ifile get "PageNotFound_html"] } } } when HTTP_RESPONSE {
if { [HTTP::status] eq "404" } { HTTP::redirect "https://${host}/PageNotFound?url=${path}" HTTP::header insert "X-Frame-Options" "DENY" HTTP::header insert "X-XSS-Protection" "1; mode=block" HTTP::header insert "X-Content-Type-Options" "'nosniff'" }
}
1 Reply
- Jad_Tabbara__J1
Cirrostratus
Hello Pedinopa,
Try this
when HTTP_REQUEST { set host [HTTP::host] set path [HTTP::path] switch $path { "/PageNotFound" { HTTP::respond 200 content [ifile get "PageNotFound_html"] "X-Frame-Options" "DENY" "X-XSS-Protection" "1; mode=block" "X-Content-Type-Options" "'nosniff'" "Connection" "Close" } } } when HTTP_RESPONSE { if { [HTTP::status] eq "404" } { HTTP::redirect "https://${host}/PageNotFound?url=${path}" } }
Please give a feedback
Hope it helps
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