ALIYUN::SLB::Rule

更新时间:
复制 MD 格式

The ALIYUN::SLB::Rule resource adds forwarding rules to a specified HTTP or HTTPS listener.

Syntax

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

Properties

Property name

Type

Required

Update allowed

Description

Constraints

ListenerPort

Integer

Yes

No

The frontend listening port of the Server Load Balancer instance.

The value ranges from 1 to 65535.

RuleList

List

Yes

No

The forwarding rules to add.

A single request can add up to 10 forwarding rules.

Each forwarding rule contains the following parameters:

  • RuleName

  • Domain

  • Url

  • VServerGroupId

Specify either Domain or Url, or both.

Note

The combination of Domain and Url must be unique within the same listener.

LoadBalancerId

String

Yes

No

The ID of the Server Load Balancer instance.

None

ListenerProtocol

String

No

No

The frontend protocol used by the instance.

None

RuleList syntax

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

RuleList properties

Property name

Type

Required

Update allowed

Description

Constraints

Url

String

No

No

The access path.

  • The length must be between 2 and 80 characters.

  • It must start with a forward slash (/) and can contain letters, digits, and the following special characters:

    -/.%?#&.

Domain

String

No

No

The request domain name associated with the forwarding rule.

None

VServerGroupId

String

Yes

No

The ID of the target vServer group for this forwarding rule.

None

RuleName

String

Yes

No

The name of the forwarding rule.

The name must be 1 to 40 characters in length and can contain letters, digits, and the following special characters:

-/._.

The names of different rules within the same listener must be unique.

AdvancedSettings

Map

No

No

The advanced configuration of the server.

None

AdvancedSettings syntax

"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 properties

Property name

Type

Required

Update allowed

Description

Constraints

Cookie

String

No

No

The cookie configured on the server.

The cookie must be 1 to 200 characters in length. It can contain only ASCII letters and digits. It cannot contain commas, semicolons, or spaces. It cannot start with $.

This parameter is required and takes effect only when StickySession is set to on and StickySessionType is set to server.

StickySession

String

No

No

Specifies whether to enable session persistence.  

Valid values:

  • on: Enables session persistence.

  • off: Disables session persistence.

Note

This parameter is required and takes effect when ListenerSync is set to off. If ListenerSync is set to on, the configuration is the same as the listener configuration.

HealthCheckConnectPort

Integer

No

No

The port on the backend server used for health checks. 

The value ranges from 1 to 65535.

Note

This parameter takes effect when HealthCheck is set to on. If this parameter is empty and HealthCheck is set to on, the backend port of the listener is used by default.

HealthCheck

String

No

No

Specifies whether to enable health checks.

Valid values:

  • on: Enables health checks.

  • off: Disables health checks.

Note

This parameter takes effect when ListenerSync is set to off. If ListenerSync is set to on, the configuration is the same as the listener configuration.

HealthCheckURI

String

No

No

The URI used for health checks.

This parameter takes effect when HealthCheck is set to on.

CookieTimeout

Integer

No

No

The cookie timeout period.

Value: 1 to 86400 seconds.

Note

This parameter is required and takes effect only when StickySession is set to on and StickySessionType is set to insert.

HealthCheckHttpCode

String

No

No

The HTTP status codes that indicate a normal health check status.

Separate multiple status codes with commas.

Valid values: http_2xx, http_3xx, http_4xx, and http_5xx.

Note

This parameter takes effect when HealthCheck is set to on.

HealthyThreshold

Integer

No

No

The health check threshold.

The number of consecutive successful health checks required to change the health check status of a backend server from failed to Normal. Value: 2 to 10.

Note

This parameter takes effect when HealthCheck is set to on.

UnhealthyThreshold

Integer

No

No

The unhealthy check threshold.

The number of consecutive failed health checks required to change the health check status of a backend server from Normal to failed. Value: 2 to 10.

Note

This parameter takes effect when HealthCheck is set to on.

Scheduler

String

No

No

The scheduling algorithm.

Valid values:

  • wrr (default): Backend servers with higher weights are polled more frequently.

  • rr: Distributes external requests to backend servers sequentially based on the access order.

Note

This parameter takes effect when ListenerSync is set to off. If ListenerSync is set to on, the configuration is the same as the listener configuration.

HealthCheckDomain

String

No

No

The domain name used for health checks.

Valid values:

  • $_ip: The private IP address of the backend server. If you specify an IP address or leave this parameter empty, Server Load Balancer uses the private IP address of each backend server as the domain name for health checks.

  • domain: The domain name must be 1 to 80 characters in length and can contain only letters, digits, periods (.), and hyphens (-).

Note

This parameter takes effect when HealthCheck is set to on.

ListenerSync

String

No

No

Specifies whether the forwarding rule inherits health check, session persistence, and scheduling algorithm configurations from the listener.

Valid values:

  • off: Does not inherit listener configurations. The forwarding rule uses custom health check and session persistence configurations.

  • on: Inherits listener configurations.

HealthCheckInterval

Integer

No

No

The health check interval.

Value: 1 to 50 seconds.

Note

This parameter takes effect when HealthCheck is set to on.

HealthCheckTimeout

Integer

No

No

The timeout period for a health check response.  

If a backend server, such as an ECS instance, does not return a health check response within the specified timeout period, the health check fails. Unit: seconds. The value ranges from 1 to 300.

StickySessionType

String

No

No

The method used to handle cookies.  

Valid values:

  • insert: Inserts a cookie.

  • server: Rewrites a cookie.

Return value

Fn::GetAtt

Rules: A list of forwarding rules.

Examples

YAML example

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 example

{
  "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"]
      }
    }
  }
}