Nota
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
Applies to: ✔️ Front Door Standard ✔️ Front Door Premium
本文介绍如何实现安全性标头以阻止基于浏览器的漏洞攻击,例如 HTTP Strict-Transport-Security (HSTS)、X-XSS-Protection、Content-Security-Policy 或 X-Frame-Options。 基于安全性的属性也可以用 Cookie 来定义。
下面的示例演示如何向与路由中的路径匹配的所有传入请求添加 Content-Security-Policy 标头。 在这里,我们仅允许来自受信任的站点 https://contoso.azure-api.cn
的脚本在我们的应用程序上运行。
Prerequisites
Azure Front Door。 有关详细信息,请参阅快速入门:创建 Front Door。
如果不熟悉规则集功能,请查看如何 设置规则集 。
在 Azure 门户中添加 Content-Security-Policy 标头
Go to the Azure Front Door Standard/Premium profile and select Rule Set under Settings.
Select Add to add a new rule set. Give the Rule Set a Name and then provide a Name for the rule. 选择“添加操作”,然后选择“响应头” 。
Set the operator to Append to add this header as a response to all of the incoming requests for this route.
Add the header name: Content-Security-Policy and define the values this header should accept. 在此方案中,我们选择
"script-src 'self' https://contoso.azure-api.cn"
。将想要的所有规则添加到配置后,请记住将规则集与路由相关联。 This step is required for the rule set to take action.
Note
In this scenario, we didn't add match conditions to the rule. 与关联路由中定义的路径匹配的所有传入请求都应用了此规则。 To apply it only to a subset of those requests, add your specific match conditions to this rule.
Important
如果将 Web 应用程序防火墙(WAF)与 Azure Front Door 配合使用,并且它阻止了请求,即使已在 Azure Front Door 上启用,HSTS 标头也不会添加到请求中。
清理资源
删除规则
在前面的步骤中,你已使用规则集配置了 Content-Security-Policy 标头。 If you no longer want a rule, you can select the Rule Set and then select Delete rule.
删除规则集
如果要删除规则集,请务必在删除前取消它与所有路由的关联。 有关删除规则集的详细指南,请参阅 Azure Front Door 中的配置规则集。