Updated on 2024-04-09 GMT+08:00

Updating a Forwarding Policy

Function

This API is used to update a forwarding policy.

Calling Method

For details, see Calling APIs.

URI

PUT /v3/{project_id}/elb/l7policies/{l7policy_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

l7policy_id

Yes

String

Specifies the forwarding policy ID.

project_id

Yes

String

Specifies the project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Specifies the token used for IAM authentication.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

l7policy

Yes

UpdateL7PolicyOption object

Specifies the forwarding policy.

Table 4 UpdateL7PolicyOption

Parameter

Mandatory

Type

Description

admin_state_up

No

Boolean

Specifies the administrative status of the forwarding policy. The default value is true.

This parameter is unsupported. Please do not use it.

description

No

String

Provides supplementary information about the forwarding policy.

Minimum: 0

Maximum: 255

name

No

String

Specifies the forwarding policy name.

Minimum: 0

Maximum: 255

redirect_listener_id

No

String

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

Note:

  • This parameter cannot be left blank or set to null when action is set to REDIRECT_TO_LISTENER.

  • The listener's protocol must be 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

Specifies the ID of the backend server group that requests will be forwarded to.

  • This parameter is valid and mandatory only when action is set to REDIRECT_TO_POOL. The specified backend server group cannot be the default backend server group associated with the listener, or any backend server group associated with the forwarding policies of other listeners.

  • This parameter cannot be specified when action is set to REDIRECT_TO_LISTENER.

redirect_pools_config

No

Array of UpdateRedirectPoolsConfig objects

Specifies the backend server groups that requests are forwarded to. A maximum of 5 backend server groups can be configured for a forwarding policy.

redirect_pools_sticky_session_config

No

UpdateRedirectPoolsStickySessionConfig object

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 groups.

This parameter is unsupported for shared load balancers. If it is passed, an error will be returned.

redirect_url_config

No

UpdateRedirectUrlConfig object

Specifies the URL to which requests are forwarded.

For dedicated load balancers, this parameter will take effect only when advanced forwarding is enabled (enhance_l7policy_enable is set to true). If it is passed when 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.

Format: 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 inherited. 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. For shared load balancers, this parameter is unsupported. If it is passed, an error will be returned.

fixed_response_config

No

UpdateFixtedResponseConfig object

Specifies the configuration of the page that will be returned. This parameter will take effect 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 the value of action is not FIXED_RESPONSE.

For shared load balancers, this parameter is unsupported. If it is passed, an error will be returned.

redirect_pools_extend_config

No

UpdateRedirectPoolsExtendConfig object

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

rules

No

Array of CreateRuleOption objects

Lists the forwarding rules in the forwarding policy.

The 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.

For details, see the description of l7rule.

priority

No

Integer

Specifies the forwarding policy priority. A smaller value indicates a higher priority. The value must be unique for each forwarding policy of the same listener.

This parameter is available only for dedicated load balancers and will take effect 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 action is set to REDIRECT_TO_LISTENER, the value can only be 0, indicating that REDIRECT_TO_LISTENER has the highest priority.

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

  • If enhance_l7policy_enable is set to true and this parameter is not passed, the priority will set to a sum of 1 and the highest priority of existing forwarding policy in the same listener by default. There will be two cases:

a) If the highest priority of existing forwarding policies is the maximum (10,000), the forwarding policy will fail to create because the final priority for creating the forwarding policy is the sum of 1 and 10,000, which exceeds the maximum. In this case, please specify a value or adjust the priorities of existing forwarding policies.

b) If no forwarding policies exist, the highest priority of existing forwarding policies will be set to 1 by default.

For shared load balancers, this parameter is unsupported.

Minimum: 0

Maximum: 10000

Table 5 UpdateRedirectPoolsConfig

Parameter

Mandatory

Type

Description

pool_id

Yes

String

Specifies the ID of the backend server group.

weight

No

String

Specifies the weight of the backend server group. The value ranges from 1 (default) to 100. Requests are routed to backend server groups based on their weights. Backend server groups with higher weights receive proportionately more requests. No requests will be routed to a backend server group with a weight of 0.

Default: 1

Table 6 UpdateRedirectPoolsStickySessionConfig

Parameter

Mandatory

Type

Description

enable

No

Boolean

Specifies whether to enable sticky session for backend server groups configured in a forwarding policy. The default value is false, indicating that sticky session is disabled.

timeout

No

Integer

Specifies the duration that a session persists.

The value ranges from 1 to 1440 (default), in minutes.

Table 7 UpdateRedirectUrlConfig

Parameter

Mandatory

Type

Description

protocol

No

String

Specifies the protocol for redirection.

The value can be HTTP, HTTPS, or ${protocol}. The default value is ${protocol}, indicating that the protocol of the request will be used.

Minimum: 1

Maximum: 36

host

No

String

Specifies the host name that requests are redirected to. The value can contain only letters, digits, hyphens (-), and periods (.) and must start with a letter or digit. The default value is ${host}, indicating that the host of the request will be used.

Default: ${host}

Minimum: 1

Maximum: 128

port

No

String

Specifies the port that requests are redirected to. The default value is ${port}, indicating that the port of the request will be used.

Default: ${port}

Minimum: 1

Maximum: 16

path

No

String

Specifies the path that requests are redirected to. The default value is ${path}, indicating that the path of the request will be used.

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

Default: ${path}

Minimum: 1

Maximum: 128

query

No

String

Specifies the query string set in the URL for redirection. The default value is ${query}, indicating that the query string of the request will be used.

For example, in the URL https://www.example.com:8080/elb?type=loadbalancer, ${query} indicates 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.

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

Default: ${query}

Minimum: 0

Maximum: 128

status_code

No

String

Specifies the status code returned after the requests are redirected.

The value can be 301, 302, 303, 307, or 308.

Minimum: 1

Maximum: 16

insert_headers_config

No

UpdateInsertHeadersConfig object

Specifies the headers you want to write into the request that matches the condition.

remove_headers_config

No

UpdateRemoveHeadersConfig object

Specifies the headers you want to remove from the request that matches the condition.

Table 8 UpdateFixtedResponseConfig

Parameter

Mandatory

Type

Description

status_code

No

String

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

Minimum: 1

Maximum: 16

content_type

No

String

Specifies the format of the response body.

The value can be text/plain, text/css, text/html, application/javascript, or application/json.

Minimum: 1

Maximum: 64

message_body

No

String

Specifies the content of the response message body.

Minimum: 0

Maximum: 1024

insert_headers_config

No

UpdateInsertHeadersConfig object

Specifies the headers you want to write into the request that matches the condition.

remove_headers_config

No

UpdateRemoveHeadersConfig object

Specifies the headers you want to remove from the request that matches the condition.

traffic_limit_config

No

UpdateTrafficLimitConfig object

Specifies how requests are limited.

Table 9 UpdateRedirectPoolsExtendConfig

Parameter

Mandatory

Type

Description

rewrite_url_enable

No

Boolean

Specifies whether to enable URL redirection.

rewrite_url_config

No

UpdateRewriteUrlConfig object

Specifies the URL that requests are directed to. This parameter takes effect only when action is set to REDIRECT_TO_POOL.

insert_headers_config

No

UpdateInsertHeadersConfig object

Specifies the headers you want to write into the request that matches the condition.

remove_headers_config

No

UpdateRemoveHeadersConfig object

Specifies the headers you want to remove from the request that matches the condition.

traffic_limit_config

No

UpdateTrafficLimitConfig object

Specifies how requests are limited.

Table 10 UpdateRewriteUrlConfig

Parameter

Mandatory

Type

Description

host

No

String

Specifies the domain name that requests are redirected to. The domain name can contain only letters, digits, hyphens (-), and periods (.), and must start with a letter or digit.

The default value is ${host}, indicating that the host of the request will be used.

path

No

String

Specifies the path that requests are redirected to. The value must start with a slash (/) and can contain only letters, digits, and special characters: _~';@^-%#&$.+?,=!:|/() $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 #.

The default value is ${path}, indicating that the path of the request will be used.

query

No

String

Specifies the query string set in the URL for redirection. The value can contain only letters, digits, and special characters: !$&'()+,-./:;=?@^_` The letters in the name are case-sensitive. $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 #.

The default value is ${query}, indicating that the query string of the request will be used.

Table 11 UpdateInsertHeadersConfig

Parameter

Mandatory

Type

Description

configs

Yes

Array of UpdateInsertHeaderConfig objects

Specifies the headers you want to write into the request that matches the condition.

Table 12 UpdateInsertHeaderConfig

Parameter

Mandatory

Type

Description

key

Yes

String

Specifies the key of the header you want to write into the request that matches the condition. The value is a string of 1 to 40 case-insensitive characters. Only letters, digits, hyphens (-), and underscores (_) are allowed. The key cannot be the following: 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.

value_type

Yes

String

Specifies the value type. The value can be USER_DEFINED, REFERENCE_HEADER, or SYSTEM_DEFINED.

value

Yes

String

Specifies the value of the header. 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.

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

Table 13 UpdateRemoveHeadersConfig

Parameter

Mandatory

Type

Description

configs

Yes

Array of UpdateRemoveHeaderConfig objects

Specifies the headers you want to remove from the request that matches the condition.

Table 14 UpdateRemoveHeaderConfig

Parameter

Mandatory

Type

Description

key

Yes

String

Specifies the header you want to remove from the request that matches the condition. The value is a string of 1 to 40 case-insensitive characters. Only letters, digits, hyphens (-), and underscores (_) are allowed. The key cannot be the following: 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.

Table 15 UpdateTrafficLimitConfig

Parameter

Mandatory

Type

Description

qps

No

Integer

Specifies the maximum number of queries per second (QPS). The value ranges from 0 to 1,00,000. 0 indicates that QPS is not limited.

Minimum: 0

Maximum: 100000

per_source_ip_qps

No

Integer

Specifies the maximum number of queries per second (QPS) from a source IP address. This parameter is not available for QUIC listeners. The value can be 0 or null. The value ranges from 0 to 1,00,000. 0 indicates that QPS is not limited. If qps is not set to 0, per_source_ip_qps must be specified a smaller value than qps.

Minimum: 0

Maximum: 100000

burst

No

Integer

Specifies the maximum number of queries per second (QPS) from a source IP address. The value ranges from 0 to 1,00,000. If the number of requests exceeds the value specified for qps but not reaches the value specified for burst, 503 status code will not be returned.

Minimum: 0

Maximum: 100000

Table 16 CreateRuleOption

Parameter

Mandatory

Type

Description

admin_state_up

No

Boolean

Specifies the administrative status of the forwarding rule. The default value is true.

This parameter is unsupported. Please do not use it.

compare_type

Yes

String

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

  • EQUAL_TO: exact match.

  • REGEX: regular expression match

  • STARTS_WITH: prefix match

Note:

  • 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.

key

No

String

Specifies the key of match content. For example, if the request header is used for forwarding, key is the request header.

This parameter is unsupported. Please do not use it.

Minimum: 0

Maximum: 255

value

Yes

String

Specifies the value of the match content. For example, if a domain name is used for matching, value is the domain name. This parameter is valid only when conditions is left blank.

  • If type is set to HOST_NAME, the value can contain letters, digits, hyphens (-), periods (.), and asterisks () and must start with a letter or digit. If you want to use a wildcard domain name, enter an asterisk () 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 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.

Minimum: 1

Maximum: 128

project_id

No

String

Specifies the project ID.

Minimum: 32

Maximum: 32

type

Yes

String

Specifies the type of the forwarding rule. The value can be one of the following:

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

  • PATH: A URL will be used for matching.

  • METHOD: An HTTP request method will be used for matching.

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

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

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

  • COOKIE: A cookie will be used for matching.

Note:

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 or QUERY_STRING, multiple forwarding rules can be created for each type.

invert

No

Boolean

Specifies whether reverse matching is supported. The value can be true or false (default).

This parameter is unsupported. Please do not use it.

conditions

No

Array of CreateRuleCondition objects

Specifies the matching conditions of the forwarding rule. This parameter is available only when enhance_l7policy_enable is set to true.

If conditions is specified, parameters key and value will not take effect, and the conditions value will contain all conditions configured for the forwarding rule. The keys in the list must be the same, whereas each value must be unique.

Table 17 CreateRuleCondition

Parameter

Mandatory

Type

Description

key

No

String

Specifies the key of match item.

  • If type is set to HOST_NAME, PATH, METHOD, or SOURCE_IP, this parameter is left blank.

  • If type is set to HEADER, key indicates the name of the HTTP header parameter. The value 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. 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 supported.

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

Minimum: 1

Maximum: 128

value

Yes

String

Specifies the value of the match item.

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

  • If type is set to PATH, key is left blank, 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 the 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 HTTP 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 1 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 supported. Asterisks (*) and question marks (?) are allowed. An asterisk can match zero or more characters, and a question mark can match 1 character.

  • If type is set to METHOD, key is left blank, 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 left blank, 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.]

All values of the condition list in a fowwarding rule must be unique.

Minimum: 1

Maximum: 128

Response Parameters

Status code: 200

Table 18 Response body parameters

Parameter

Type

Description

request_id

String

Specifies the request ID. The value is automatically generated.

l7policy

L7Policy object

Specifies the forwarding policy.

Table 19 L7Policy

Parameter

Type

Description

action

String

Specifies where requests will be forwarded. The value can be one of the following:

  • REDIRECT_TO_POOL: Requests will be forwarded to another backend server group.

  • REDIRECT_TO_LISTENER: Requests will be redirected to an HTTPS listener.

  • REDIRECT_TO_URL: Requests will be redirected to another URL.

  • FIXED_RESPONSE: A fixed response body will be returned.

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.

Note:

  • 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.

admin_state_up

Boolean

Specifies the administrative status of the forwarding policy. The default value is true.

This parameter is unsupported. Please do not use it.

description

String

Provides supplementary information about the forwarding policy.

id

String

Specifies the forwarding policy ID.

listener_id

String

Specifies the ID of the listener to which the forwarding policy is added.

name

String

Specifies the forwarding policy name.

Minimum: 1

Maximum: 255

position

Integer

Specifies the forwarding policy priority. This parameter cannot be updated.

This parameter is unsupported. Please do not use it.

Minimum: 1

Maximum: 100

priority

Integer

Specifies the forwarding policy priority. A smaller value indicates a higher priority. The value must be unique for each forwarding policy of the same listener.

This parameter is available only for dedicated load balancers and will take effect 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 action is set to REDIRECT_TO_LISTENER, the value can only be 0, indicating that REDIRECT_TO_LISTENER has the highest priority.

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

  • If enhance_l7policy_enable is set to true and this parameter is not passed, the priority will set to a sum of 1 and the highest priority of existing forwarding policy in the same listener by default. There will be two cases:

a) If the highest priority of existing forwarding policies is the maximum (10,000), the forwarding policy will fail to create because the final priority for creating the forwarding policy is the sum of 1 and 10,000, which exceeds the maximum. In this case, please specify a value or adjust the priorities of existing forwarding policies.

b) If no forwarding policies exist, the highest priority of existing forwarding policies will be set to 1 by default.

For shared load balancers, this parameter is unsupported.

project_id

String

Specifies the project ID of the forwarding policy.

provisioning_status

String

Specifies the provisioning status of the forwarding policy.

The value can be ACTIVE or ERROR.

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

  • ERROR: Another forwarding policy of the same listener has the same forwarding rule.

redirect_pool_id

String

Specifies the ID of the backend server group that requests will be forwarded to. This parameter is valid and mandatory only when action is set to REDIRECT_TO_POOL.

redirect_listener_id

String

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

Note:

  • 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

Specifies the URL to which requests are forwarded.

Format: protocol://host:port/path?query

This parameter is unsupported. Please do not use it.

rules

Array of RuleRef objects

Lists the forwarding rules in the forwarding policy.

redirect_url_config

RedirectUrlConfig object

Specifies the URL to which requests are forwarded.

For dedicated load balancers, this parameter will take effect only when advanced forwarding is enabled (enhance_l7policy_enable is set to true). If it is passed when 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.

Format: 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 inherited. 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. For shared load balancers, this parameter is unsupported. If it is passed, an error will be returned.

redirect_pools_config

Array of RedirectPoolsConfig objects

Specifies the backend server groups that requests are forwarded to. A maximum of 5 backend server groups can be configured for a forwarding policy.

redirect_pools_sticky_session_config

RedirectPoolsStickySessionConfig object

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 groups.

This parameter is unsupported for shared load balancers. If it is passed, an error will be returned.

redirect_pools_extend_config

RedirectPoolsExtendConfig object

Specifies the backend server group that the requests are forwarded to.This parameter is valid only when action is set to REDIRECT_TO_POOL.

fixed_response_config

FixtedResponseConfig object

Specifies the configuration of the page that will be returned. This parameter will take effect 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 the value of action is not FIXED_RESPONSE.

For shared load balancers, this parameter is unsupported. If it is passed, an error will be returned.

created_at

String

Specifies the time when the forwarding policy was added. The format is yyyy-MM-dd'T'HH:mm:ss'Z' (UTC time).

This is a new field in this version, and it will not be returned for resources associated with existing dedicated load balancers and for resources associated with existing and new shared load balancers.

updated_at

String

Specifies the time when the forwarding policy was updated. The format is yyyy-MM-dd'T'HH:mm:ss'Z' (UTC time).

This is a new field in this version, and it will not be returned for resources associated with existing dedicated load balancers and for resources associated with existing and new shared load balancers.

Table 20 RuleRef

Parameter

Type

Description

id

String

Specifies the forwarding rule ID.

Table 21 RedirectUrlConfig

Parameter

Type

Description

protocol

String

Specifies the protocol for redirection.

The value can be HTTP, HTTPS, or ${protocol}. The default value is ${protocol}, indicating that the protocol of the request will be used.

Minimum: 1

Maximum: 36

host

String

Specifies the host name that requests are redirected to. The value can contain only letters, digits, hyphens (-), and periods (.) and must start with a letter or digit. The default value is ${host}, indicating that the host of the request will be used.

Default: ${host}

Minimum: 1

Maximum: 128

port

String

Specifies the port that requests are redirected to. The default value is ${port}, indicating that the port of the request will be used.

Default: ${port}

Minimum: 1

Maximum: 16

path

String

Specifies the path that requests are redirected to. The default value is ${path}, indicating that the path of the request will be used. The value can contain only letters, digits, and special characters _-';@^- %#&$.*+?,=!:|/()[]{} and must start with a slash (/).

Default: ${path}

Minimum: 1

Maximum: 128

query

String

Specifies the query string set in the URL for redirection. The default value is ${query}, indicating that the query string of the request will be used.

For example, in the URL https://www.example.com:8080/elb?type=loadbalancer, ${query} indicates 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.

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

Default: ${query}

Minimum: 0

Maximum: 128

status_code

String

Specifies the status code returned after the requests are redirected.

The value can be 301, 302, 303, 307, or 308.

Minimum: 1

Maximum: 16

insert_headers_config

InsertHeadersConfig object

Specifies the headers you want to write into the request that matches the condition.

remove_headers_config

RemoveHeadersConfig object

Specifies the headers you want to remove from the request that matches the condition.

Table 22 RedirectPoolsConfig

Parameter

Type

Description

pool_id

String

Specifies the ID of the backend server group.

weight

Integer

Specifies the weight of the backend server group. The value ranges from 0 to 100. Requests are routed to backend server groups based on their weights. Backend server groups with higher weights receive proportionately more requests. No requests will be routed to a backend server group with a weight of 0.

Minimum: 0

Maximum: 100

Table 23 RedirectPoolsStickySessionConfig

Parameter

Type

Description

enable

Boolean

Specifies whether to enable sticky session for backend server groups configured in a forwarding policy. The default value is false, indicating that sticky session is disabled.

Default: false

timeout

Integer

Specifies the duration that a session persists.

The value ranges from 1 to 1440 (default), in minutes.

Table 24 RedirectPoolsExtendConfig

Parameter

Type

Description

rewrite_url_enable

Boolean

Specifies whether to set rewrite_url_enable to true.

rewrite_url_config

RewriteUrlConfig object

Specifies the URL for the backend server group that requests are forwarded to. This parameter is mandatory when action is set to REDIRECT_TO_POOL.

insert_headers_config

InsertHeadersConfig object

Specifies the headers you want to write into the request that matches the condition.

remove_headers_config

RemoveHeadersConfig object

Specifies the headers you want to remove from the request that matches the condition.

traffic_limit_config

TrafficLimitConfig object

Specifies how requests are limited.

Table 25 RewriteUrlConfig

Parameter

Type

Description

host

String

Specifies the domain name that requests are redirected to. The domain name can contain only letters, digits, hyphens (-), and periods (.), and must start with a letter or digit.

The default value is ${host}, indicating that the host of the request will be used.

path

String

Specifies the path that requests are redirected to.

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 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 #.

The default value is ${path}, indicating that the path of the request will be used.

query

String

Specifies the query string set in the URL for redirection. The value is case-sensitive and can contain only letters, digits, and special characters !$&'()+,-./:;=?@^_`. $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 #.

The default value is ${query}, indicating that the query string of the request will be used.

Table 26 FixtedResponseConfig

Parameter

Type

Description

status_code

String

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

Minimum: 1

Maximum: 16

content_type

String

Specifies the format of the response body.

The value can be text/plain, text/css, text/html, application/javascript, or application/json.

Minimum: 0

Maximum: 32

message_body

String

Specifies the content of the response message body.

Minimum: 0

Maximum: 1024

insert_headers_config

InsertHeadersConfig object

Specifies the headers you want to write into the request that matches the condition.

remove_headers_config

RemoveHeadersConfig object

Specifies the headers you want to remove from the request that matches the condition.

traffic_limit_config

TrafficLimitConfig object

Specifies how requests are limited.

Table 27 InsertHeadersConfig

Parameter

Type

Description

configs

Array of InsertHeaderConfig objects

Specifies the headers you want to write into the request that matches the condition.

Table 28 InsertHeaderConfig

Parameter

Type

Description

key

String

Specifies the key of the header you want to write into the request that matches the condition. The value is a string of 1 to 40 case-insensitive characters. Only letters, digits, hyphens (-), and underscores (_) are allowed. The key cannot be the following: 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.

value_type

String

Specifies the value type. The value can be USER_DEFINED, REFERENCE_HEADER, or SYSTEM_DEFINED.

value

String

Specifies the value of the header. 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. The value can contain 1 to 128 characters.

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

Table 29 RemoveHeadersConfig

Parameter

Type

Description

configs

Array of RemoveHeaderConfig objects

Specifies the headers you want to remove from the request that matches the condition.

Table 30 RemoveHeaderConfig

Parameter

Type

Description

key

String

Specifies the header you want to remove from the request that matches the condition. The value is a string of 1 to 40 case-insensitive characters. Only letters, digits, hyphens (-), and underscores (_) are allowed. The key cannot be the following: 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.

Table 31 TrafficLimitConfig

Parameter

Type

Description

qps

Integer

Specifies the maximum number of queries per second (QPS). The value ranges from 0 to 1,00,000. 0 indicates that QPS is not limited.

Minimum: 0

Maximum: 100000

per_source_ip_qps

Integer

Specifies the maximum number of queries per second (QPS) from a source IP address. This parameter is not available for QUIC listeners. The value can be 0 or null. The value ranges from 0 to 1,00,000. 0 indicates that QPS is not limited. If qps is not set to 0, per_source_ip_qps must be specified a smaller value than qps.

Minimum: 0

Maximum: 100000

burst

Integer

Specifies the maximum number of queries per second (QPS) from a source IP address. The value ranges from 0 to 1,00,000. If the number of requests exceeds the value specified for qps but not reaches the value specified for burst, 503 status code will not be returned.

Minimum: 0

Maximum: 100000

Example Requests

Modifying a forwarding policy

PUT https://{ELB_Endpoint}/v3/99a3fff0d03c428eac3678da6a7d0f24/elb/l7policies/cf4360fd-8631-41ff-a6f5-b72c35da74be

{
  "l7policy" : {
    "name" : "My policy.",
    "description" : "Update policy.",
    "redirect_listener_id" : "48a97732-449e-4aab-b561-828d29e45050"
  }
}

Example Responses

Status code: 200

Successful request.

{
  "request_id" : "e5c07525-1470-47b6-9b0c-567527a036aa",
  "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

200

Successful request.

Error Codes

See Error Codes.