我想停止我的angular应用程序,使其在IFRAME中打开。我在google上读了一些文章,知道为了实现这一点,我们必须设置X-Frame-Options。但是我没有找到给这个头的方法。
有谁能帮我在angular-4中实现这一点吗?
发布于 2018-09-18 17:58:43
这与angular app没有任何关系。它是IIS中的一个设置。要在IIS服务器中设置X-Frame-Options,请执行以下操作:
X-Frame-Options的站点。在显示选项的右侧中间窗格中,双击X-Frame-Options,在Value字段中键入` `SAMEORIGIN。有关点击劫持攻击的更多详细信息,请访问here
希望这能解决你的问题。
发布于 2019-08-21 18:15:49
以下是Angular的解决方案:
http://taimooradilbadshah.blogspot.com/2014/06/the-clickjacking-attack-and-x-frame.html
我在服务器(IIS)上创建了一个web.config文件,并将构建(Dist)代码放在该文件中。
它也适用于角度路由(忽略使用散列标签(#))。
web.config
<?xml version="1.0"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-Frame-Options" value="SAMEORIGIN" />
</customHeaders>
</httpProtocol>
<rewrite>
<rules>
<rule name="AngularJS Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/angularProject/index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>你可以把上面的代码放在你的网站上查看:
https://www.lookout.net/test/clickjack.html
谢谢
https://stackoverflow.com/questions/51740643
复制相似问题