通过优先流量功能,您可以指定 Cloudflare One Appliance(前称 Magic WAN Connector)应优先处理哪些应用程序。列表外的应用程序流量会排在优先流量之后。
与分流流量类似,优先流量也通过检查 DNS 请求工作。
在 Cloudflare One Appliance 中添加或移除优先流量应用程序之前,您需要在账户级别创建包含待配置应用程序的列表。目前,只能通过 API 的 managed_app_id 端点向此列表添加应用程序或修改列表。
要向账户添加应用程序:
发送 POST 请求,将新应用程序添加到账户。
Required API token permissions
At least one of the following token permissions is required:Magic WAN WriteMagic Transit Write
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/magic/apps" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"managed_app_id": "<APP_ID>",
"name": "<APP_NAME>",
"type": "<APP_TYPE>"
}'{
"result": {
"account_app_id": "eb09v665c0784618a3e4ba9809258fd4",
"name": "<APP_NAME>",
"type": "<APP_TYPE>",
},
"success": true,
"errors": [],
"messages": []
}现在可以将这个新应用程序添加到 Cloudflare One Appliance 的优先流量列表。
需要为每个现有站点配置优先流量应用程序,因为这是一项按站点设置的配置。
-
登录 Cloudflare One 仪表板 ↗,然后前往 Networks。
-
前往 Connectors > Appliances > Profiles。
-
选择您要配置的 Cloudflare One Appliance > Edit(编辑)。
-
选择 Traffic Steering。
-
在 Prioritized traffic 中,选择 Create。
-
从列表中选择一个或多个应绕过 Cloudflare 过滤的应用程序。您也可以使用搜索框。
-
选择 Save(保存)。
Connector 现在会优先处理所选应用程序的流量。
-
发送
GET请求,列出与账户关联的应用程序。
At least one of the following token permissions is required:Required API token permissions
Magic WAN WriteMagic WAN ReadMagic Transit ReadMagic Transit Write
List Appsbash curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/magic/apps" \ --request GET \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"{ "result": [ { "managed_app_id": "<APP_ID>", "name": "<APP_NAME>", "type": "File Sharing", "hostnames": [ "<app_name.com>", "<app-name.info>" ] } ] }记下要添加的每个应用程序的
"managed_app_id"值。 -
发送
POST请求,将新应用程序添加到优先流量策略。
At least one of the following token permissions is required:Required API token permissions
Magic WAN WriteMagic Transit Write
Create a new App Configbash curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/magic/sites/$SITE_ID/app_configs" \ --request POST \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ --json '{ "managed_app_id": "<MANAGED_APP_ID>", "breakout": true }'{ "result": { "account_app_id": "<APP_ID>", "name": "<APP_NAME>", "type": "<BREAKOUT_OR_PRIORITY>" }, "success": true, "errors": [], "messages": [] }
-
登录 Cloudflare One 仪表板 ↗,然后前往 Networks。
-
前往 Connectors > Appliances > Profiles。
-
选择要配置的 Appliance > Edit。
-
选择 Traffic Steering。
-
在 Prioritized traffic 中,找到要删除的应用程序,选择其旁边的 three dots,再选择 Remove application traffic。
-
(可选)如果应用程序列表有多页,可以使用搜索框快速查找目标应用程序。
需要从每个现有站点删除优先流量应用程序,因为这是一项按站点设置的配置。
-
发送
GET请求,列出与站点关联的应用程序。
At least one of the following token permissions is required:Required API token permissions
Magic WAN WriteMagic WAN ReadMagic Transit ReadMagic Transit Write
List App Configsbash curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/magic/sites/$SITE_ID/app_configs" \ --request GET \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"{ "result": [ { "id": "<APP_ID>", "site_id": "<SITE_ID>", "managed_app_id": "<APP_NAME>", "breakout": true } ] }记下要删除的应用程序的
"id"值。 -
发送
DELETE请求,从优先流量策略删除应用程序。curl "https://api.cloudflare.com/client/v4/accounts/%7Baccount_id%7D/magic/sites/%7Bsite_id%7D/app_configs/%7Bid%7D" \ --request DELETE{ "result": { "id": "<APP_ID>", "site_id": "<SITE_ID>", "managed_app_id": "<APP_NAME>", "breakout": true }, "success": true, "errors": [], "messages": [] }