Updated on 2025-08-29 GMT+08:00

Adding a Forwarding Policy

Function

This API is used to add a forwarding policy to a listener.

Constraints

Forwarding policies can be added to only to HTTP or HTTPS listeners.

Calling Method

For details, see Calling APIs.

URI

POST /v3/{project_id}/elb/l7policies

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition: Specifies the project ID. For details about how to obtain a project ID, see Obtaining a Project ID.

Constraints: N/A

Range: The value can contain a maximum of 32 characters, including digits and lowercase letters.

Default value: N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition: Specifies the token used for IAM authentication.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

l7policy

Yes

CreateL7PolicyOption object

Definition: Specifies the forwarding policy.

Table 4 CreateL7PolicyOption

Parameter

Mandatory

Type

Description

action

Yes

String

Definition: Specifies the action of the forwarding policy.

Constraints:

  • REDIRECT_TO_LISTENER has the highest priority. If requests are to be redirected to an HTTPS listener, other forwarding policies of the listener will become invalid.

  • If action is set to REDIRECT_TO_POOL, the listener's protocol must be HTTP, HTTPS, or TERMINATED_HTTPS.

  • If action is set to REDIRECT_TO_LISTENER, the listener's protocol must be HTTP.

Range:

  • REDIRECT_TO_POOL: Requests are forwarded to another backend server group.

  • REDIRECT_TO_LISTENER: Requests are redirected to an HTTPS listener.

  • REDIRECT_TO_URL: Requests are redirected to another URL.

  • FIXED_RESPONSE: A fixed response body is returned.

admin_state_up

No

Boolean

Definition: Specifies the administrative status of the forwarding policy.

Constraints: The value can only be true.

description

No

String

Definition: Provides supplementary information about the forwarding policy.

listener_id

Yes

String

Definition: Specifies the ID of the listener with which the forwarding policy is associated.

Constraints:

  • If action is set to REDIRECT_TO_POOL, the listener's protocol must be HTTP or HTTPS.

  • If action is set to REDIRECT_TO_LISTENER, the listener's protocol must be HTTP.

name

No

String

Definition: Specifies the forwarding policy name.

position

No

Integer

Definition: Specifies the priority of the forwarding policy.

Constraint: The value cannot be updated.

This parameter is unsupported. Please do not use it.

priority

No

Integer

Definition: Specifies the priority of the forwarding policy. A smaller value indicates a higher priority.

Constraints:

  • The priority must be unique for forwarding policies of the same listener.

  • This parameter takes effect only when enhance_l7policy_enable is set to true. If this parameter is passed and enhance_l7policy_enable is set to false, an error will be returned.

  • If enhance_l7policy_enable is set to false, forwarding policies are automatically prioritized based on the original policy sorting logic. The priorities of domain names are independent from each other. For the same domain name, the priorities are sorted in the order of exact match (EQUAL_TO), prefix match (STARTS_WITH), and regular expression match (REGEX). If the matching types are the same, the longer the path is, the higher the priority is. If a forwarding policy contains only a domain name without a path specified, the path is /, and prefix match is used by default.

Range:

  • If action is set to REDIRECT_TO_LISTENER, the priority ranges from 0 to 10,000.

  • If action is set to other values, the priority ranges from 1 to 10,000.

Default value:

  • If this parameter is not passed and enhance_l7policy_enable is set to false, the priority of the new forwarding policy is 1.

  • If action is set to REDIRECT_TO_LISTENER, the priority of the new forwarding policy is 0.

  • If action is set to other values, the priority of the new forwarding policy will be a sum of 1 and the highest priority of existing forwarding policy in the same listener by default.

    • If there is no forwarding policy, the priority of a new forwarding policy will be 1 by default.

    • If the priority of an existing forwarding policy is the maximum value (10,000), the forwarding policy will fail to be created because the maximum value will be exceeded. In this case, specify a value or adjust the priorities of existing forwarding policies.

project_id

No

String

Definition: Specifies the ID of the project where the forwarding policy is used.

redirect_listener_id

No

String

Definition: Specifies the ID of the listener to which requests are redirected. This parameter is mandatory when action is set to REDIRECT_TO_LISTENER.

Constraints:

  • The listener's protocol must be HTTPS or TERMINATED_HTTPS.

  • A listener added to another load balancer is not allowed.

  • This parameter cannot be passed in the API for adding or updating a forwarding policy if action is set to REDIRECT_TO_POOL.

redirect_pool_id

No

String

Definition: Specifies the ID of the backend server group to which requests will be forwarded.

Constraints:

  • This parameter takes effect only when action is set to REDIRECT_TO_POOL.

  • If this parameter is specified when action is set to REDIRECT_TO_LISTENER, an error will be reported.

redirect_url

No

String

Definition: Specifies the URL to which requests will be forwarded.

Constraints: The value must be in the format of protocol://host:port/path?query.

redirect_url_config

No

CreateRedirectUrlConfig object

Definition: Specifies the URL to which requests are forwarded.

Constraints:

  • This parameter takes effect only when enhance_l7policy_enable is set to true. If this parameter is passed and enhance_l7policy_enable is set to false, an error will be returned.

  • This parameter is mandatory when action is set to REDIRECT_TO_URL. It cannot be specified if the value of action is not REDIRECT_TO_URL. Otherwise, an error is reported.

Default value: The value must be in the format of protocol://host:port/path?query.

At least one of the four parameters (protocol, host, port, and path) must be passed, or their values cannot be set to ${xxx} at the same time.

${xxx} indicates that the value in the request will be used. For example, ${host} indicates the host in the URL to be redirected.

The values of protocol and port cannot be the same as those of the associated listener, and either host or path must be passed or their values cannot be ${xxx} at the same time.

fixed_response_config

No

CreateFixtedResponseConfig object

Definition: Specifies the configuration of the page that will be returned.

Constraints:

  • This parameter takes effect only when enhance_l7policy_enable is set to true. If this parameter is passed and enhance_l7policy_enable is set to false, an error will be returned.

  • This parameter is mandatory when action is set to FIXED_RESPONSE. It cannot be specified if action is set to other values.

redirect_pools_extend_config

No

CreateRedirectPoolsExtendConfig object

Definition: Specifies the backend server group that requests are forwarded to.

Constraints: This parameter takes effect only when action is set to REDIRECT_TO_POOL.

rules

No

Array of CreateL7PolicyRuleOption objects

Definition: Lists the forwarding rules in the forwarding policy.

Constraints:

  • Each list can contain a maximum of 10 forwarding rules (if conditions is specified, a condition is considered as a rule). If type is set to HOST_NAME, PATH, METHOD, or SOURCE_IP, only one forwarding rule can be created for each type.

  • The entire list will be replaced if you update it.

  • The forwarding rule cannot be created when action is set to REDIRECT_TO_LISTENER.

Table 5 CreateRedirectUrlConfig

Parameter

Mandatory

Type

Description

protocol

No

String

Definition: Specifies the protocol for redirection.

Range:

  • HTTP

  • HTTPS

  • ${protocol}: indicates that the protocol in the request will be used.

Default value: ${protocol}

host

No

String

Definition: Specifies the name of the host that requests are redirected to.

Range: The value can contain only letters, digits, hyphens (-), and periods (.) and must start with a letter or digit.

Default value: ${host}, indicating that the host in the request will be used.

port

No

String

Definition: Specifies the port that requests are redirected to.

Default value: ${port}, indicating that the port in the request will be used.

path

No

String

Definition: Specifies the path that requests are redirected to.

Range: The value can contain only letters, digits, and special characters: _~';@^-%#&$.*+?,=!:|\/()[]{} and must start with a slash (/). $1, $2, $3, and all the way to $9 match the wildcard asterisk (*) in the requested URL.

Default value: ${path}, indicating that the path in the request will be used.

query

No

String

Definition: Specifies the query string set in the URL for redirection. The following is an example:

In the URL https://www.example.com:8080/elb?type=loadbalancer, if this parameter is set to ${query}&name=my_name, the URL will be redirected to https://www.example.com:8080/elb?type=loadbalancer&name=my_name. In the example, ${query} indicates type=loadbalancer.

Range: The value can contain only letters, digits, and the special characters: !$&'()*+,-./:;=?@^_`. The letters are case-sensitive. $1, $2, $3, and all the way to $9 match the wildcard asterisk (*) in the requested URL.

Default value: ${query}, indicating that the query string in the request will be used.

status_code

Yes

String

Definition: Specifies the status code returned after the requests are redirected.

Range:

  • 301

  • 302

  • 303

  • 307

  • 308

insert_headers_config

No

CreateInsertHeadersConfig object

Definition: Specifies the headers you want to write into the request that matches the forwarding rule.

remove_headers_config

No

CreateRemoveHeadersConfig object

Definition: Specifies the headers you want to remove from the request that matches the forwarding rule.

Table 6 CreateInsertHeadersConfig

Parameter

Mandatory

Type

Description

configs

Yes

Array of CreateInsertHeaderConfig objects

Definition: Specifies the headers you want to write into the request that matches the forwarding rule.

Table 7 CreateInsertHeaderConfig

Parameter

Mandatory

Type

Description

key

Yes

String

Definition: Specifies the key of the header you want to write into the request that matches the forwarding rule.

Constraints: The following cannot be used as a key.

connection, upgrade, content-length, transfer-encoding, keep-alive, te, host, cookie, remoteip, authority, x-forwarded-host, x-forwarded-for, x-forwarded-for-port, x-forwarded-tls-certificate-id, x-forwarded-tls-protocol, x-forwarded-tls-cipher, x-forwarded-elb-ip, x-forwarded-port, x-forwarded-elb-id, x-forwarded-elb-vip, x-real-ip, x-forwarded-proto, x-nuwa-trace-ne-in, or x-nuwa-trace-ne-out

Range: The value can contain 1 to 40 characters, including letters (case-insensitive), digits, hyphens (-), and underscores (_).

value_type

Yes

String

Definition: Specifies the value type of the header.

Range: USER_DEFINED, REFERENCE_HEADER, or SYSTEM_DEFINED

value

Yes

String

Definition: Specifies the value of the header.

Constraints: If value_type is set to SYSTEM_DEFINED, the value can be CLIENT-PORT, CLIENT-IP, ELB-PROTOCOL, ELB-ID, ELB-PORT, ELB-EIP, or ELB-VIP.

Range: The value can contain 1 to 128 characters. ASCII codes 32 through 127 printable characters, asterisk (*), and question mark (?) are also supported. The value cannot start or end with a space.

Table 8 CreateRemoveHeadersConfig

Parameter

Mandatory

Type

Description

configs

Yes

Array of CreateRemoveHeaderConfig objects

Definition: Specifies the headers you want to remove from the request that matches the forwarding rule.

Table 9 CreateRemoveHeaderConfig

Parameter

Mandatory

Type

Description

key

Yes

String

Definition: Specifies the key of the header you want to remove from the request that matches the forwarding rule.

Constraints: The following cannot be used as a key.

connection, upgrade, content-length, transfer-encoding, keep-alive, te, host, cookie, remoteip, authority, x-forwarded-host, x-forwarded-for, x-forwarded-for-port, x-forwarded-tls-certificate-id, x-forwarded-tls-protocol, x-forwarded-tls-cipher, x-forwarded-elb-ip, x-forwarded-port, x-forwarded-elb-id, x-forwarded-elb-vip, x-real-ip, x-forwarded-proto, x-nuwa-trace-ne-in, or x-nuwa-trace-ne-out

Range: The value can contain 1 to 40 characters, including letters (case-insensitive), digits, hyphens (-), and underscores (_).

Table 10 CreateFixtedResponseConfig

Parameter

Mandatory

Type

Description

status_code

Yes

String

Definition: Specifies the HTTP status code.

Range: 200-299, 400-499, 500-599.

content_type

No

String

Definition: Specifies the format of the returned body.

Range:

  • text/plain

  • text/css

  • text/html

  • application/javascript

  • application/json

Default value: text/plain

message_body

No

String

Definition: Specifies the content of the response message body.

Table 11 CreateRedirectPoolsExtendConfig

Parameter

Mandatory

Type

Description

rewrite_url_enable

No

Boolean

Definition: Specifies whether to set rewrite_url_enable to true.

rewrite_url_config

No

CreateRewriteUrlConfig object

Definition: Specifies the URL for the backend server group that requests are forwarded to.

Constraints: This parameter takes effect only when action is set to REDIRECT_TO_POOL.

Table 12 CreateRewriteUrlConfig

Parameter

Mandatory

Type

Description

host

No

String

Definition: Specifies the domain name of the host that requests are redirected to.

Range: The value can contain letters, digits, hyphens (-), and periods (.), and must start with a letter or digit.

Default value: ${host}, indicating that the host in the request will be used.

path

No

String

Definition: Specifies the path that requests are redirected to. $1, $2, $3, and all the way to $9 match the wildcard asterisk (*) in the request URL. If the number of regular expression match groups is less than the specified number, ${path} is empty. If the dollar sign ($) is followed by a letter, the matching result is empty until the next special character appears, for example, $abc#123, and the matching result is #123. If the dollar sign ($) is followed by a special character, for example, $#, the matching result is $#.

Range: The value must start with a slash (/) and can contain only letters, digits, and special characters: _~';@^-%#&$.+?,=!:|/()

Default value: ${path}, indicating that the path in the request will be used.

query

No

String

Definition: Specifies the query string set in the URL for redirection. $1, $2, $3, and all the way to $9 match the wildcard asterisk (*) in the request URL. If the number of regular expression match groups is less than the specified number, ${path} is empty. If the dollar sign ($) is followed by a letter, the matching result is empty until the next special character appears, for example, $abc#123, and the matching result is #123. If the dollar sign ($) is followed by a special character, for example, $#, the matching result is $#.

Range: The value can contain only letters, digits, and the special characters: !$&'()+,-./:;=?@^_`. The letters are case-sensitive.

Default value: ${query}, indicating that the query string in the request will be used.

Table 13 CreateL7PolicyRuleOption

Parameter

Mandatory

Type

Description

admin_state_up

No

Boolean

Definition: Specifies the administrative status of the forwarding rule.

Constraints: The value can only be true.

type

Yes

String

Definition: Specifies the forwarding rule type.

Constraints:

If type is set to HOST_NAME, PATH, METHOD, or SOURCE_IP, only one forwarding rule can be created for each type. If type is set to HEADER and QUERY_STRING, multiple forwarding rules can be created for each type.

Range:

  • HOST_NAME: A domain name will be used for matching.

  • PATH: A URL will be used for matching.

  • METHOD: A request method will be used for matching.

  • HEADER: A request header will be used for matching.

  • QUERY_STRING: A query string will be used for matching.

  • SOURCE_IP: A source IP address will be used for matching.

  • COOKIE: A cookie will be used for matching.

compare_type

Yes

String

Definition: Specifies how requests are matched with the forwarding rule.

Constraints:

  • If type is set to HOST_NAME, the value can only be EQUAL_TO, and asterisks (*) can be used as wildcard characters.

  • If type is set to PATH, the value can be REGEX, STARTS_WITH, or EQUAL_TO.

  • If type is set to METHOD or SOURCE_IP, the value can only be EQUAL_TO.

  • If type is set to HEADER or QUERY_STRING, the value can only be EQUAL_TO, asterisks (*) and question marks (?) can be used as wildcard characters.

Range:

  • EQUAL_TO: exact match

  • REGEX: regular expression match

  • STARTS_WITH: prefix match

invert

No

Boolean

Definition: Specifies whether reverse matching is supported.

Range: true or false

Default value: false

This parameter is unsupported. Please do not use it.

key

No

String

Definition: Specifies the key of the match item. For example, if an HTTP header is used for matching, key is the name of the HTTP header parameter.

This parameter is unsupported. Please do not use it.

value

Yes

String

Definition: Specifies the value of the match item. For example, if a domain name is used for matching, value is the domain name.

Constraints:

  • This parameter takes effect only when conditions is left blank.

  • If type is set to HOST_NAME, the value can contain letters, digits, hyphens (-), and periods (.), or *, and must start with a letter, digit, or *. If you want to use a wildcard domain name, enter * as the leftmost label of the domain name.

  • If type is set to PATH and compare_type to STARTS_WITH or EQUAL_TO, the value must start with a slash (/) and can contain only letters, digits, and special characters: _~';@^-%#&$.*+?,=!:|\/()[]{}

  • If type is set to METHOD, SOURCE_IP, HEADER, or QUERY_STRING, this parameter will not take effect, and conditions will be used to specify the key and value.

conditions

No

Array of CreateRuleCondition objects

Definition: Specifies the conditions contained in a forwarding rule.

Constraints:

  • This parameter takes effect only when enhance_l7policy_enable is set to true.

  • If conditions is set for a forwarding rule, the values of key and value are ignored.

  • All keys in the conditions of a rule must be the same, and the values must be unique.

Table 14 CreateRuleCondition

Parameter

Mandatory

Type

Description

key

No

String

Definition: Specifies the key of match item.

Constraints: All keys in the conditions list in the same rule must be the same.

Range:

  • If type is set to HOST_NAME, PATH, METHOD, or SOURCE_IP, this parameter is an empty string.

  • If type is set to HEADER, key indicates the name of the HTTP header parameter, and value indicates the value of the request header parameter. Each key can contain 1 to 40 characters, including letters, digits, hyphens (-), and underscores (_).

  • If type is set to QUERY_STRING, key indicates the name of the query parameter, and value indicates the value of the query parameter. The key is case sensitive and can contain 1 to 128 characters. Spaces, square brackets ([ ]), curly brackets ({ }), angle brackets (< >), backslashes (), double quotation marks (" "), pound signs (#), ampersands (&), vertical bars (|), percent signs (%), and tildes (~) are not allowed.

value

Yes

String

Definition: Specifies the value of the match item.

Constraints:

  • The key of each condition in a forwarding rule must be the same.

  • The value of each condition in a forwarding rule must be unique.

Range:

  • If type is set to HOST_NAME, key is always an empty string and value indicates the domain name. Each value can contain 1 to 128 characters, including letters, digits, hyphens (-), periods (.), and asterisks (*), and must start with a letter, digit, or *. If you want to use a wildcard domain name, enter * as the leftmost label of the domain name.

  • If type is set to PATH, key is always an empty string and value indicates the request path, which can contain 1 to 128 characters. If compare_type is set to STARTS_WITH or EQUAL_TO for a forwarding rule, the value must start with a slash (/) and can contain only letters, digits, and special characters: _~';@^-%#&$.*+?,=!:|\/()[]{}

  • If type is set to HEADER, key indicates the name of the HTTP header parameter, and value indicates the value of the request header parameter. The value can contain 1 to 128 characters. Asterisks (*) and question marks (?) are allowed, but spaces and double quotation marks are not allowed. An asterisk can match zero or more characters, and a question mark can match one character.

  • If type is set to QUERY_STRING, key indicates the name of the query parameter, and value indicates the value of the query parameter. The value is case sensitive and can contain 1 to 128 characters. Spaces, square brackets ([ ]), curly brackets ({ }), angle brackets (< >), backslashes (), double quotation marks (" "), pound signs (#), ampersands (&), vertical bars (|), percent signs (%), and tildes (~) are not allowed. Asterisks (*) and question marks (?) are allowed. An asterisk can match zero or more characters, and a question mark can match one character.

  • If type is set to METHOD, key is always an empty string and value indicates the HTTP method. The value can be GET, PUT, POST, DELETE, PATCH, HEAD, or OPTIONS.

  • If type is set to SOURCE_IP, key is always an empty string and value indicates the source IP address of the request. The value is an IPv4 or IPv6 CIDR block, for example, 192.168.0.2/32 or 2049::49/64.

Response Parameters

Status code: 201

Table 15 Response body parameters

Parameter

Type

Description

request_id

String

Definition: Specifies the request ID.

Range: The value is automatically generated, and can contain characters including digits, lowercase letters, and hyphens (-).

l7policy

L7Policy object

Definition: Specifies the forwarding policy.

Table 16 L7Policy

Parameter

Type

Description

action

String

Definition: Specifies the action of the forwarding policy.

Constraints:

  • REDIRECT_TO_LISTENER has the highest priority. If requests are to be redirected to an HTTPS listener, other forwarding policies of the listener will become invalid.

  • If action is set to REDIRECT_TO_POOL, the listener's protocol must be HTTP, HTTPS, or TERMINATED_HTTPS.

  • If action is set to REDIRECT_TO_LISTENER, the listener's protocol must be HTTP.

Range:

  • REDIRECT_TO_POOL: Requests are forwarded to another backend server group.

  • REDIRECT_TO_LISTENER: Requests are redirected to an HTTPS listener.

  • REDIRECT_TO_URL: Requests are redirected to another URL.

  • FIXED_RESPONSE: A fixed response body is returned.

admin_state_up

Boolean

Definition: Specifies the administrative status of the forwarding policy.

Constraints: The value can only be true.

description

String

Definition: Provides supplementary information about the forwarding policy.

id

String

Definition: Specifies the forwarding policy ID.

listener_id

String

Definition: Specifies the ID of the listener with which the forwarding policy is associated.

name

String

Definition: Specifies the forwarding policy name.

position

Integer

Definition: Specifies the priority of the forwarding policy. The priority cannot be updated.

This parameter is unsupported. Please do not use it.

priority

Integer

Definition: Specifies the priority of the forwarding policy. A smaller value indicates a higher priority.

Constraints:

  • The priority must be unique for forwarding policies of the same listener.

  • This parameter takes effect only when enhance_l7policy_enable is set to true. If this parameter is passed and enhance_l7policy_enable is set to false, an error will be returned.

  • If enhance_l7policy_enable is set to false, forwarding policies are automatically prioritized based on the original policy sorting logic. The priorities of domain names are independent from each other. For the same domain name, the priorities are sorted in the order of exact match (EQUAL_TO), prefix match (STARTS_WITH), and regular expression match (REGEX). If the matching types are the same, the longer the path is, the higher the priority is. If a forwarding policy contains only a domain name without a path specified, the path is /, and prefix match is used by default.

Range:

  • If action is set to REDIRECT_TO_LISTENER, the priority ranges from 0 to 10,000.

  • If action is set to other values, the priority ranges from 1 to 10,000.

Default value:

  • If this parameter is not passed and enhance_l7policy_enable is set to false, the priority of the new forwarding policy is 1.

  • If action is set to REDIRECT_TO_LISTENER, the priority of the new forwarding policy is 0.

  • If action is set to other values, the priority of the new forwarding policy will be a sum of 1 and the highest priority of existing forwarding policy in the same listener by default.

    • If there is no forwarding policy, the priority of a new forwarding policy will be 1 by default.

    • If the priority of an existing forwarding policy is the maximum value (10,000), the forwarding policy will fail to be created because the maximum value will be exceeded. In this case, specify a value or adjust the priorities of existing forwarding policies.

project_id

String

Definition: Specifies the ID of the project where the forwarding policy is used.

provisioning_status

String

Definition: Specifies the provisioning status of the forwarding policy.

Range:

  • ACTIVE (default): The forwarding policy is provisioned successfully.

redirect_pool_id

String

Definition: Specifies the ID of the backend server group to which requests will be forwarded.

Constraints: This parameter takes effect only when action is set to REDIRECT_TO_POOL.

redirect_listener_id

String

Definition: Specifies the ID of the listener to which requests are redirected.

Constraints:

  • This parameter is mandatory when action is set to REDIRECT_TO_LISTENER.

  • The listener's protocol must be HTTPS or TERMINATED_HTTPS.

  • A listener added to another load balancer is not allowed.

  • This parameter cannot be passed in the API for adding or updating a forwarding policy if action is set to REDIRECT_TO_POOL.

redirect_url

String

Definition: Specifies the URL to which requests will be forwarded.

Range: The value must be in the format of protocol://host:port/path?query.

This parameter is unsupported. Please do not use it.

rules

Array of RuleRef objects

Definition: Lists the forwarding rules in the forwarding policy.

redirect_url_config

RedirectUrlConfig object

Definition: Specifies the URL to which requests are forwarded.

Constraints:

  • This parameter takes effect only when enhance_l7policy_enable is set to true. If this parameter is passed and enhance_l7policy_enable is set to false, an error will be returned.

  • This parameter is mandatory when action is set to REDIRECT_TO_URL. It cannot be specified if the value of action is not REDIRECT_TO_URL. Otherwise, an error is reported.

Default value: The value must be in the format of protocol://host:port/path?query.

At least one of the four parameters (protocol, host, port, and path) must be passed, or their values cannot be set to ${xxx} at the same time. ${xxx} indicates that the value in the request will be used. For example, ${host} indicates the host in the URL to be redirected.

The values of protocol and port cannot be the same as those of the associated listener, and either host or path must be passed or their values cannot be ${xxx} at the same time.

redirect_pools_config

Array of RedirectPoolsConfig objects

Definition: Specifies the backend server groups that the requests are forwarded to.

Constraints: A maximum of five backend server groups can be configured for a forwarding policy.

redirect_pools_sticky_session_config

RedirectPoolsStickySessionConfig object

Definition: Specifies whether to enable sticky session for backend server groups configured for a forwarding policy. The load balancer generates a cookie after it receives a request from a client. All subsequent requests with the same cookie are routed to the same backend server group.

redirect_pools_extend_config

RedirectPoolsExtendConfig object

Definition: Specifies the backend server group that requests are forwarded to.

Constraints: This parameter takes effect only when action is set to REDIRECT_TO_POOL.

fixed_response_config

FixtedResponseConfig object

Definition: Specifies the configuration of the page that will be returned.

Constraints:

  • This parameter takes effect only when enhance_l7policy_enable is set to true. If this parameter is passed and enhance_l7policy_enable is set to false, an error will be returned.

  • This parameter is mandatory when action is set to FIXED_RESPONSE. It cannot be specified if action is set to other values.

created_at

String

Definition: Specifies the creation time.

Range: The value must be a UTC time in the yyyy-MM-dd'T'HH:mm:ss'Z' format.

updated_at

String

Definition: Specifies the update time.

Range: The value must be a UTC time in the yyyy-MM-dd'T'HH:mm:ss'Z' format.

enterprise_project_id

String

Definition: Specifies the enterprise project ID.

Table 17 RuleRef

Parameter

Type

Description

id

String

Definition: Specifies the forwarding rule ID.

Table 18 RedirectUrlConfig

Parameter

Type

Description

protocol

String

Definition: Specifies the protocol for redirection.

Range:

  • HTTP

  • HTTPS

  • ${protocol}: indicates that the protocol in the request will be used.

host

String

Definition: Specifies the name of the host that requests are redirected to.

Range: The value can contain only letters, digits, hyphens (-), and periods (.) and must start with a letter or digit.

Default value: ${host}, indicating that the host in the request will be used.

port

String

Definition: Specifies the port that requests are redirected to.

Default value: ${port}, indicating that the port in the request will be used.

path

String

Definition: Specifies the path that requests are redirected to.

Range: The value can contain only letters, digits, and special characters: _~';@^-%#&$.*+?,=!:|\/()[]{} and must start with a slash (/).

Default value: ${path}, indicating that the path in the request will be used.

query

String

Definition: Specifies the query string set in the URL for redirection. The following is an example:

In the URL https://www.example.com:8080/elb?type=loadbalancer, if this parameter is set to ${query}&name=my_name, the URL will be redirected to https://www.example.com:8080/elb?type=loadbalancer&name=my_name. In the example, ${query} indicates type=loadbalancer.

Range: The value can contain only letters, digits, and the special characters: !$&'()*+,-./:;=?@^_`. The letters are case-sensitive. $1, $2, $3, and all the way to $9 match the wildcard asterisk (*) in the requested URL.

Default value: ${query}, indicating that the query string in the request will be used.

status_code

String

Definition: Specifies the status code returned after the requests are redirected.

Range:

  • 301

  • 302

  • 303

  • 307

  • 308

Table 19 RedirectPoolsConfig

Parameter

Type

Description

pool_id

String

Definition: Specifies the backend server group ID.

weight

Integer

Definition: Specifies the weight of the backend server group. Requests are routed to backend server groups based on their weights. The larger the weight is, the higher proportion of requests the backend server group receives. If the weight is set to 0, the backend server group will not accept new requests.

Range: 0 to 100

Table 20 RedirectPoolsStickySessionConfig

Parameter

Type

Description

enable

Boolean

Definition: Specifies whether to enable sticky session for backend server groups configured in a forwarding policy.

Default value: false, indicating that sticky session is disabled.

timeout

Integer

Definition: Specifies the stickiness duration, in minutes.

Range: 1 to 1440, in minutes

Default value: 1440

Table 21 RedirectPoolsExtendConfig

Parameter

Type

Description

rewrite_url_enable

Boolean

Definition: Specifies whether to set rewrite_url_enable to true.

rewrite_url_config

RewriteUrlConfig object

Definition: Specifies the URL for the backend server group that requests are forwarded to.

Constraints: This parameter takes effect only when action is set to REDIRECT_TO_POOL.

Table 22 RewriteUrlConfig

Parameter

Type

Description

host

String

Definition: Specifies the domain name of the host that requests are redirected to.

Range: The value can contain letters, digits, hyphens (-), and periods (.), and must start with a letter or digit.

Default value: ${host}, indicating that the host in the request will be used.

path

String

Definition: Specifies the path that requests are redirected to. $1, $2, $3, and all the way to $9 match the wildcard asterisk (*) in the request URL. If the number of regular expression match groups is less than the specified number, ${path} is empty. If the dollar sign ($) is followed by a letter, the matching result is empty until the next special character appears, for example, $abc#123, and the matching result is #123. If the dollar sign ($) is followed by a special character, for example, $#, the matching result is $#.

Range: The value must start with a slash (/) and can contain only letters, digits, and special characters: _~';@^-%#&$.+?,=!:|/()

Default value: ${path}, indicating that the path in the request will be used.

query

String

Definition: Specifies the query string set in the URL for redirection. $1, $2, $3, and all the way to $9 match the wildcard asterisk (*) in the request URL. If the number of regular expression match groups is less than the specified number, ${path} is empty. If the dollar sign ($) is followed by a letter, the matching result is empty until the next special character appears, for example, $abc#123, and the matching result is #123. If the dollar sign ($) is followed by a special character, for example, $#, the matching result is $#.

Range: The value can contain only letters, digits, and the special characters: !$&'()+,-./:;=?@^_`. The letters are case-sensitive.

Default value: ${query}, indicating that the query string in the request will be used.

Table 23 FixtedResponseConfig

Parameter

Type

Description

status_code

String

Definition: Specifies the HTTP status code. The value can be any integer in the range of 200–299, 400–499, or 500–599.

content_type

String

Definition: Specifies the format of the returned body.

Range:

  • text/plain

  • text/css

  • text/html

  • application/javascript

  • application/json

message_body

String

Definition: Specifies the content of the response message body.

Example Requests

Creating a redirection for a listener

POST https://{ELB_Endpoint}/v3/99a3fff0d03c428eac3678da6a7d0f24/elb/l7policies

{
  "l7policy" : {
    "action" : "REDIRECT_TO_LISTENER",
    "listener_id" : "e2220d2a-3faf-44f3-8cd6-0c42952bd0ab",
    "redirect_listener_id" : "48a97732-449e-4aab-b561-828d29e45050"
  }
}

Example Responses

Status code: 201

Successful request.

{
  "request_id" : "b60d1d9a-5263-45b0-b1d6-2810ac7c52a1",
  "l7policy" : {
    "redirect_pool_id" : "768e9e8c-e7cb-4fef-b24b-af9399dbb240",
    "description" : "",
    "admin_state_up" : true,
    "rules" : [ {
      "id" : "c5c2d625-676b-431e-a4c7-c59cc2664881"
    } ],
    "project_id" : "7a9941d34fc1497d8d0797429ecfd354",
    "listener_id" : "cdb03a19-16b7-4e6b-bfec-047aeec74f56",
    "redirect_url" : null,
    "redirect_url_config" : null,
    "redirect_pools_config" : {
      "pool_id" : "722e9e8c-e7cb-4fef-b24b-af9399dbb240",
      "weight" : 12
    },
    "redirect_pools_sticky_session_config" : {
      "timeout" : 23,
      "enable" : false
    },
    "fixed_response_config" : null,
    "redirect_listener_id" : null,
    "action" : "REDIRECT_TO_POOL",
    "position" : 100,
    "priority" : null,
    "provisioning_status" : "ACTIVE",
    "id" : "01832d99-bbd8-4340-9d0c-6ff8f7a37307",
    "name" : "l7policy-67"
  }
}

Status Codes

Status Code

Description

201

Successful request.

Error Codes

See Error Codes.