フェーズのエントリポイントルールセット には、そのフェーズで実行されるルールの順序付き一覧があります。エントリポイントルールセット内のルールは、別のルールセットを実行できます。アカウントレベルとゾーンレベルのそれぞれで、フェーズごとにエントリポイントルールセットを持てます。
フェーズのエントリポイントルールセットへルールを 1 件以上追加するには、Rulesets API の ルールセット更新操作 のいずれかを使います。エントリポイントルールセットへルールを追加するとき、そのエントリポイントルールセットがなければ自動で作成されます。この API メソッドでは、残したいルールをすべてリクエストに含める必要があります。含めないと削除されます。
ルールセットへルールを 1 件だけ追加する場合は、ルール作成操作 のいずれかを検討してください。この場合、リクエストには新しいルールの定義だけを含めます。
次の例は、ゾーンのエントリポイントルールセットを更新する 操作を使い、http_request_firewall_managed フェーズについて、ゾーンレベルでフェーズのエントリポイントルールセットのルールを設定します。
Required API token permissions
At least one of the following token permissions is required:Response Compression WriteConfig Settings WriteDynamic URL Redirects WriteCache Settings WriteCustom Errors WriteOrigin WriteManaged headers WriteZone Transform Rules WriteMass URL Redirects WriteMagic Firewall WriteL4 DDoS Managed Ruleset WriteHTTP DDoS Managed Ruleset WriteSanitize WriteTransform Rules WriteSelect Configuration WriteBot Management WriteZone WAF WriteAccount WAF WriteAccount Rulesets WriteLogs WriteLogs Write
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets/phases/http_request_firewall_managed/entrypoint" \
--request PUT \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"rules": [
{
"action": "execute",
"action_parameters": {
"id": "<MANAGED_RULESET_ID_1>"
},
"expression": "true"
},
{
"action": "execute",
"action_parameters": {
"id": "<MANAGED_RULESET_ID_2>"
},
"expression": "true"
}
]
}'{
"result": {
"id": "<RULESET_ID>",
"name": "Default",
"description": "",
"kind": "zone",
"version": "1",
"rules": [
{
"id": "<RULE_ID_1>",
"version": "1",
"action": "execute",
"expression": "true",
"action_parameters": {
"id": "<MANAGED_RULESET_ID_1>"
},
"last_updated": "2021-06-17T15:42:37.917815Z"
},
{
"id": "<RULE_ID_2>",
"version": "1",
"action": "execute",
"expression": "true",
"action_parameters": {
"id": "<MANAGED_RULESET_ID_2>"
},
"last_updated": "2021-06-17T15:42:37.917815Z"
}
],
"last_updated": "2021-06-17T15:42:37.917815Z",
"phase": "http_request_firewall_managed"
},
"success": true,
"errors": [],
"messages": []
}次の例は、ゾーンルールセットにルールを作成する 操作を使い、ゾーンレベルでフェーズのエントリポイントルールセット(ID は $RULESET_ID)へルールを 1 件追加します。
Required API token permissions
At least one of the following token permissions is required:Response Compression WriteConfig Settings WriteDynamic URL Redirects WriteCache Settings WriteCustom Errors WriteOrigin WriteManaged headers WriteZone Transform Rules WriteMass URL Redirects WriteMagic Firewall WriteL4 DDoS Managed Ruleset WriteHTTP DDoS Managed Ruleset WriteSanitize WriteTransform Rules WriteSelect Configuration WriteBot Management WriteZone WAF WriteAccount WAF WriteAccount Rulesets WriteLogs WriteLogs Write
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets/$RULESET_ID/rules" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"action": "execute",
"action_parameters": {
"id": "<MANAGED_RULESET_ID>"
},
"expression": "true"
}'{
"result": {
"id": "<RULESET_ID>",
"name": "Zone-level phase entry point ruleset",
"description": "",
"kind": "root",
"version": "2",
"rules": [
{
"id": "<EXISTING_RULE_ID>",
"version": "1",
"action": "execute",
"expression": "true",
"action_parameters": {
"id": "<ANOTHER_MANAGED_RULESET_ID>"
},
"last_updated": "2021-03-17T15:42:37.917815Z"
},
{
"id": "<NEW_RULE_ID>",
"version": "1",
"action": "execute",
"expression": "true",
"action_parameters": {
"id": "<MANAGED_RULESET_ID>"
},
"last_updated": "2021-06-30T15:42:37.917815Z"
}
],
"last_updated": "2021-06-30T15:42:37.917815Z",
"phase": "http_request_firewall_managed"
},
"success": true,
"errors": [],
"messages": []
}