跳转到内容
本站为社区维护的非官方中文翻译,与 Cloudflare, Inc. 无关联。本站不提供账户登录,请勿在任何非官方站点输入您的 Cloudflare 账户信息。官方文档:developers.cloudflare.com

优先流量

最后更新 查看 MarkdownAgent 设置

通过优先流量功能,您可以指定 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 Write
  • Magic Transit Write
Create a new Appbash
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 Appliance

需要为每个现有站点配置优先流量应用程序,因为这是一项按站点设置的配置。

  1. 登录 Cloudflare One 仪表板 ↗,然后前往 Networks。

  2. 前往 Connectors > Appliances > Profiles。

  3. 选择您要配置的 Cloudflare One Appliance > Edit(编辑)。

  4. 选择 Traffic Steering。

  5. 在 Prioritized traffic 中,选择 Create。

  6. 从列表中选择一个或多个应绕过 Cloudflare 过滤的应用程序。您也可以使用搜索框。

  7. 选择 Save(保存)。

Connector 现在会优先处理所选应用程序的流量。

  1. 发送 GET 请求,列出与账户关联的应用程序。

    Required API token permissions

    At least one of the following token permissions is required:
    • Magic WAN Write
    • Magic WAN Read
    • Magic Transit Read
    • Magic 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" 值。

  2. 发送 POST 请求,将新应用程序添加到优先流量策略。

    Required API token permissions

    At least one of the following token permissions is required:
    • Magic WAN Write
    • Magic 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 Appliance 删除应用程序

  1. 登录 Cloudflare One 仪表板 ↗,然后前往 Networks。

  2. 前往 Connectors > Appliances > Profiles。

  3. 选择要配置的 Appliance > Edit。

  4. 选择 Traffic Steering。

  5. 在 Prioritized traffic 中,找到要删除的应用程序,选择其旁边的 three dots,再选择 Remove application traffic。

  6. (可选)如果应用程序列表有多页,可以使用搜索框快速查找目标应用程序。

需要从每个现有站点删除优先流量应用程序,因为这是一项按站点设置的配置。

  1. 发送 GET 请求,列出与站点关联的应用程序。

    Required API token permissions

    At least one of the following token permissions is required:
    • Magic WAN Write
    • Magic WAN Read
    • Magic Transit Read
    • Magic 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" 值。

  2. 发送 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": []
    }

这篇文档对您有帮助吗?