文档

ALIYUN::SLB::Rule

更新时间:

ALIYUN::SLB::Rule类型用于为指定的HTTP或HTTPS监听添加转发规则。

语法

{
  "Type": "ALIYUN::SLB::Rule",
  "Properties": {
    "ListenerPort": Integer,
    "RuleList": List,
    "LoadBalancerId": String,
    "ListenerProtocol": String
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

ListenerPort

Integer

负载均衡实例前端使用的监听端口。

取值范围:1~65535。

RuleList

List

要添加的转发规则。

一次请求中,最多可添加10条转发规则。

每条转发规则包含以下参数:

  • RuleName

  • Domain

  • Url

  • VServerGroupId

Domain和URL两者必须指定一个,也可以同时指定。

说明

Domain和URL的组合在同一个监听内必须唯一。

LoadBalancerId

String

负载均衡实例ID。

ListenerProtocol

String

实例前端使用的协议。

RuleList语法

"RuleList": [
  {
    "Url": String,
    "Domain": String,
    "VServerGroupId": String,
    "RuleName": String,
    "AdvancedSettings": Map
  }
]

RuleList属性

属性名称

类型

必须

允许更新

描述

约束

Url

String

访问路径

  • 长度为2~80个字符。

  • 以正斜线(/)开头,可包含字母、数字和以下特殊字符:

    -/.%?#&

Domain

String

转发规则关联的请求域名。

VServerGroupId

String

该转发规则的目标虚拟服务器组ID。

RuleName

String

转发规则名称。

长度为1~40个字符,可包含字母、数字和以下特殊字符:

-/._

同一个监听内不同规则的名称必须唯一。

AdvancedSettings

Map

服务器的高级配置。

AdvancedSettings语法

"AdvancedSettings": [{ 
  "Cookie": String,
  "StickySession": String,
  "HealthCheckConnectPort": Integer,
  "StickySessionType": String,
  "HealthCheckTimeout": Integer,
  "HealthCheck": String,
  "HealthCheckURI": String,
  "CookieTimeout": Integer,
  "HealthCheckHttpCode": String,
  "HealthyThreshold": Integer,
  "UnhealthyThreshold": Integer,
  "Scheduler": String,
  "HealthCheckDomain": String,
  "ListenerSync": String,
  "HealthCheckInterval": Integer 
}]

AdvancedSettings属性

属性名称

类型

必须

允许更新

描述

约束

Cookie

String

服务器上配置的Cookie。

长度为1~200个字符,只能包含ASCII英文字母和数字字符,不能包含逗号、分号或空格,也不能以$开头。

StickySessiononStickySessionTypeserver时,该参数必选且有效。

StickySession

String

是否启用会话持久。  

取值:

  • on:启用会话持久。

  • off:关闭会话持久。

说明

ListenerSyncoff时必选且有效,为on时表明与监听配置一致。

HealthCheckConnectPort

Integer

健康检查的后端服务器的端口。 

取值范围:1~65535。

说明

HealthCheckon时该参数有效,若为空且当HealthCheckon,表明默认使用监听后端端口配置。

HealthCheck

String

是否开启健康检查。

取值:

  • on:开启健康检查。

  • off:关闭健康检查。

说明

ListenerSyncoff时有效,为on时表明与监听配置一致。

HealthCheckURI

String

用于健康检查的URI。

HealthCheckon时,该参数有效。

CookieTimeout

Integer

Cookie超时时间。

取值:1~86400秒。

说明

StickySessiononStickySessionTypeinsert时,该参数必选且有效。

HealthCheckHttpCode

String

健康检查正常的HTTP状态码。

多个状态码用逗号分隔。

有效值:http_2xx、http_3xx、http_4xx、http_5xx。

说明

HealthCheckon时,该参数有效。

HealthyThreshold

Integer

健康检的阈值。

健康检查连续成功多少次后,将后端服务器的健康检查状态由失败判定为成功。取值:2~10

说明

HealthCheckon时,该参数有效。

UnhealthyThreshold

Integer

不健康检的阈值。

健康检查连续失败多少次后,将后端服务器的健康检查状态由成功判定为失败。取值:2~10

说明

HealthCheckon时,该参数有效。

Scheduler

String

调度算法。

取值:

  • wrr(默认值):权重值越高的后端服务器,被轮询到的次数(概率)也越高。

  • rr:按照访问顺序依次将外部请求依序分发到后端服务器。

说明

ListenerSyncoff时有效,为on时表明与监听配置一致。

HealthCheckDomain

String

用于健康检查的域名。

取值:

  • $_ip: 后端服务器的私网IP。当指定了IP或该参数未指定时,负载均衡会使用各后端服务器的私网IP当作健康检查使用的域名。

  • domain:域名长度为1~80字符,只能包含字母、数字、半角句号(.)和短划线(-)。

说明

HealthCheckon时,该参数有效。

ListenerSync

String

转发规则是否从监听上继承健康检查、会话保持和调度算法配置。

取值:

  • off:不继承监听配置,转发规则自定义健康检查及会话保持配置。

  • on:继承监听配置。

HealthCheckInterval

Integer

健康检查的时间间隔。

取值:1~50秒。

说明

HealthCheckon时,该参数有效。

HealthCheckTimeout

Integer

健康检查响应的超时时间。  

如果后端服务器(如ECS实例)在指定的超时时间内没有返回健康检查响应,则表示该服务器健康检查失败。 单位:秒。 取值范围:1 ~ 300。

StickySessionType

String

用于处理cookie的方法。  

取值:

  • insert:插入一个cookie

  • server:重写cookie。

返回值

Fn::GetAtt

Rules:转发规则列表。

示例

YAML示例

ROSTemplateFormatVersion: '2015-09-01'
Resources:
  Rule:
    Type: ALIYUN::SLB::Rule
    Properties:
      ListenerPort:
        Ref: ListenerPort
      RuleList:
        Fn::Split:
          - ','
          - Ref: RuleList
          - Ref: RuleList
      LoadBalancerId:
        Ref: LoadBalancerId
Parameters:
  ListenerPort:
    Type: Number
    Description: |-
      The front-end HTTPS listener port of the Server Load Balancer instance. Valid value:
      1-65535
    MaxValue: 65535
    MinValue: 1
  RuleList:
    MinLength: 1
    Type: CommaDelimitedList
    Description: The forwarding rules to add.
    MaxLength: 10
  LoadBalancerId:
    Type: String
    Description: The ID of Server Load Balancer instance.
Outputs:
  Rules:
    Description: A list of forwarding rules. Each element of rules contains "RuleId".
    Value:
      Fn::GetAtt:
        - Rule
        - Rules

JSON示例

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Resources": {
    "Rule": {
      "Type": "ALIYUN::SLB::Rule",
      "Properties": {
        "ListenerPort": {
          "Ref": "ListenerPort"
        },
        "RuleList": {
          "Fn::Split": [",", {
            "Ref": "RuleList"
          }, {
            "Ref": "RuleList"
          }]
        },
        "LoadBalancerId": {
          "Ref": "LoadBalancerId"
        }
      }
    }
  },
  "Parameters": {
    "ListenerPort": {
      "Type": "Number",
      "Description": "The front-end HTTPS listener port of the Server Load Balancer instance. Valid value:\n1-65535",
      "MaxValue": 65535,
      "MinValue": 1
    },
    "RuleList": {
      "MinLength": 1,
      "Type": "CommaDelimitedList",
      "Description": "The forwarding rules to add.",
      "MaxLength": 10
    },
    "LoadBalancerId": {
      "Type": "String",
      "Description": "The ID of Server Load Balancer instance."
    }
  },
  "Outputs": {
    "Rules": {
      "Description": "A list of forwarding rules. Each element of rules contains \"RuleId\".",
      "Value": {
        "Fn::GetAtt": ["Rule", "Rules"]
      }
    }
  }
}
  • 本页导读 (1)
文档反馈