コンテンツにスキップ

POSTの例

この例では、単一のAPI呼び出しを使用していくつかのファイアウォールルールを作成します。

リクエスト
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/firewall/rules" \
--header "X-Auth-Email: <EMAIL>" \
--header "X-Auth-Key: <API_KEY>" \
--header "Content-Type: application/json" \
--data '[
{
"filter": {
"id": "<FILTER_ID_1>"
},
"action": "allow",
"description": "オフィスからのログインに挑戦しない"
},
{
"filter": {
"id": "<FILTER_ID_2>"
},
"action": "challenge",
"description": "ログインに挑戦"
},
{
"filter": {
"id": "<FILTER_ID_3>"
},
"action": "js_challenge",
"description": "JSチャレンジサイト"
},
{
"filter": {
"id": "<FILTER_ID_4>"
},
"action": "allow",
"description": "挑戦なしでAPIトラフィックを許可"
}
]'
レスポンス
{
"result": [
{
"id": "<RULE_ID_1>",
"paused": false,
"description": "オフィスからのログインに挑戦しない",
"action": "allow",
"priority": null,
"filter": {
"id": "<FILTER_ID_1>",
"expression": "ip.src in {2400:cb00::/32 2803:f800::/32 2c0f:f248::/32 2a06:98c0::/29} and (http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")",
"paused": false,
"description": "オフィスからのログイン"
}
},
{
"id": "<RULE_ID_2>",
"paused": false,
"description": "ログインに挑戦",
"action": "challenge",
"priority": null,
"filter": {
"id": "<FILTER_ID_2>",
"expression": "(http.request.uri.path ~ \"^.*/wp-login.php$\" or http.request.uri.path ~ \"^.*/xmlrpc.php$\")",
"paused": false,
"description": "ログイン"
}
},
{
"id": "<RULE_ID_3>",
"paused": false,
"description": "JSチャレンジサイト",
"action": "js_challenge",
"priority": null,
"filter": {
"id": "<FILTER_ID_3>",
"expression": "not http.request.uri.path matches \"^/api/.*$\"",
"paused": false,
"description": "not /api"
}
},
{
"id": "<RULE_ID_4>",
"paused": false,
"description": "挑戦なしでAPIトラフィックを許可",
"action": "allow",
"priority": null,
"filter": {
"id": "<FILTER_ID_4>",
"expression": "http.request.uri.path matches \"^/api/.*$\"",
"paused": false,
"description": "/api"
}
}
],
"success": true,
"errors": [],
"messages": []
}