Applies to: ✔️ Front Door Standard ✔️ Front Door Premium
本文介绍如何使用 Azure 门户创建规则集和第一组规则。 你还将了解如何从“规则集”页面或 Front Door 管理器将规则集关联到路由。
Prerequisites
- 在配置规则集之前,必须先创建 Azure Front Door 标准版或高级版配置文件。 有关详细信息,请参阅创建 Azure Front Door 配置文件。
在 Azure 门户中配置规则集
转到 Azure Front Door 配置文件。 Select Rule sets under Settings in the left side menu pane. Select + Add, then give the rule set a name.
若要创建第一个规则,请指定规则名称。 然后,选择“+ 添加条件”或“+ 添加操作”来定义规则。 一个规则最多可添加 10 个条件和 5 个操作。 本示例使用服务器变量将“设备类型”追加到来自“移动”设备类型的请求的响应头。 For more information, see match conditions and actions.
Note
- 若要从规则中删除某个条件或操作,请使用相应条件或操作右侧的垃圾桶图标。
- 若要创建适用于所有传入流量的规则,请不要指定任何条件。
- 若要在满足某个特定规则后停止对其余规则进行评估,请选中“停止评估剩余规则”。 如果选中此选项,则无论满足何种匹配条件,都不会执行该规则集中的所有剩余规则以及与路由关联的所有剩余规则集。
- 规则引擎中的所有路径都区分大小写。
- Header names should adhere to RFC 7230.
你可以使用箭头按钮向上或向下移动规则,以在规则集中设置规则的优先级。 列表按升序排列,因此首先列出的是优先级最高的规则。
Once you create all the rules you need, select Save to complete the creation of your rule set.
现在,可以将规则集与路由关联,使其生效。 你可以在“规则集”页面关联规则集,也可以从 Front Door 管理器执行此操作。
“规则集”页:
在“规则集”页面中,选择“未关联”链接,将规则集关联到路由。
然后在“关联路由”页面中,选择要与该规则集关联的终结点和路由。
Select Next to change the rule set order if you have multiple rule sets for the selected route. 规则集将按所列顺序处理。 你可以通过选择规则集并使用页面顶部的按钮来更改顺序。 Select Associate to complete the route association.
Note
在此页中,只能将一个规则集与一个路由关联。 若要将规则集与另一个路由关联,请使用 Front Door 管理器。
现在,规则集已与路由关联。 你可以查看响应头,确认是否已添加设备类型。
Front Door 管理器:
In the Front Door manager, select the ... next to the route you want to configure, then select Edit route.
On the Update route page, under Rules, select the rule sets you want to associate with the route from the dropdown. 你还可以更改规则集的顺序。
Select Update to save the route configuration.
删除规则集
如果不再需要 Azure Front Door 配置文件中的某个规则集,请执行以下步骤将其移除:
Navigate to the Rule set page under Settings.
Select the ... next to the rule set you want to remove and select Disassociate from all routes.
After the rule set is disassociated, select the ... again. Select Delete and then confirm by selecting Yes.
重复上述步骤,以移除 Azure Front Door 配置文件中的其他规则集(如有)。
Next steps
了解如何使用规则集添加安全性标头。