我想使用 X-Frame-Options 为我的网站添加点击劫持保护。我网站上的几个页面显示在一个框架中,所以我想保护它们,但同时正确呈现它们。据我了解,我需要在 X-Frame-Options 值中使用 SAMEORIGIN 选项。但SAMEORIGIN到底是什么意思?它的意思是同一个网站吗?我发现的官方描述不是很清楚 2 页共享相同的"起源"是什么意思......这里有人可以帮助我吗?谢谢!
"origin"是网站的方案+主机+端口。也就是说,http://example.com/
有(http, example.com, 80)
的起源. https://example.com/
是不同的起源,即(https, example.com, 443)
。
将x-frame-options
页眉设置为SAMEORIGIN
从http://example.com/
提供的页面意味着只有http://example.com/
上的其他页面才能在框架中加载该页面。
使用 X-Frame-Options customHeaders - 将多个 uri/domain 添加到 web.config?
解决方案 ->将其添加到您的 web.config
<httpProtocol>
<customHeaders>
<add name="Content-Security-Policy" value="frame-ancestors 'self' website1.com website2.com;"/>
</customHeaders>
</httpProtocol>