admin管理员组文章数量:1122832
A large number of client sites are on an NGINX hosting platform and a large number of those sites are using industry specific eComm software... ...the eComm provider is pushing all of their customers to ensure that they've got robust security and the only item we're not in compliance with is X-Frame-Options
being set to either SAMEORIGIN
or DENY
.
Normally, we'd do this with .htaccess
but on this host, there is no .htaccess
. So instead we've created a simple plugin that doesn't nothing but set the HTTP header X-Frame-Options: SAMEORIGIN
.
if( !function_exists( 'wpse60844_set_xframe' ) ) :
function wpse60844_set_xframe() {
header( 'X-Frame-Options: SAMEORIGIN' );
}
add_action( 'send_headers', 'wpse60844_set_xframe', 99 );
endif;
With that above, we can run a check and see if it's listed in the sent headers and it is...
var_dump( headers_list() )
shows me that X-Frame-Options
is set to SAMEORIGIN
.
However, any site scanner we run, and every browser's DEV tools, don't show that it's set.
Have also already tried to remove_headers()
first and then re-set it and have tried to run the function on init
instead of send_headers
. Neither of these seem to make a difference.
UPDATE / ANSWER
The code in the question, as it turns out, is fine. It's correct for LAMP stacks and it appears that it just doesn't work on NGINX (LNMP stack) OR it just doesn't work on FlyWheel hosted sites. (That's yet to be determined because I only have access to NGINX via FlyWheel hosted sites, so I haven't yet been able to test this elsewhere.) Kinda sucks because the whole purpose of the function was to add the header on servers where I don't get to use .htaccess
, like FlyWheel, so the one place where I would need this, is the one place it doesn't work. On all the other LAMP sites we work with, we'd just add it to .htaccess
.
本文标签: phpUsing sendheaders action to set XFrameOptions not really working
版权声明:本文标题:php - Using `send_headers` action to set `X-Frame-Options` not really working 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736287724a1927941.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论