优先流量 (Prioritized traffic) 允许您定义 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(流量引导)。
- 在 ${props.featureName},选择 ${props.dashName === "CF1 Cloudflare WAN" ? "Create" : "Assign application traffic"}。
- 从列表中选择一个 or 多个应当绕过 Cloudflare 过滤的应用程序。您也可以使用搜索框。
- 选择 Save(保存)。
您选择的应用程序的流量将 ${props.whatHappensApp}。
-
发送
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(配置文件)。
- 选择您想要配置的设备 > Edit(编辑)。
- 选择 Traffic Steering(流量引导)。
- 在 ${props.featureName} 中,找到您要删除的应用程序 > 选择其旁边的三个点 > 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": [] }