หน้านี้ยังไม่พร้อมใช้งานในภาษาท้องถิ่นของคุณ เรากำลังพยายามอย่างหนักเพื่อเพิ่มเวอร์ชันภาษาอื่น ๆ เพิ่มเติม ขอบคุณสำหรับการสนับสนุนเสมอมา
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
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Specifies the project ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Specifies the token used for IAM authentication. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
l7policy |
Yes |
CreateL7PolicyOption object |
Specifies the forwarding policy. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
action |
Yes |
String |
Specifies where requests will be forwarded. Value options:
Note:
|
admin_state_up |
No |
Boolean |
Specifies the administrative status of the forwarding policy. Note: The value can only be true. |
description |
No |
String |
Provides supplementary information about the forwarding policy. |
listener_id |
Yes |
String |
Specifies the ID of the listener to which the forwarding policy is added. Note:
|
name |
No |
String |
Specifies the forwarding policy name. |
position |
No |
Integer |
Specifies the forwarding policy priority. The value cannot be updated. This parameter is unsupported. Please do not use it. |
priority |
No |
Integer |
Specifies the forwarding policy priority. A smaller value indicates a higher priority. Value ranges:
Default value options:
Note:
This parameter is supported by forwarding policies of shared load balancers. |
project_id |
No |
String |
Specifies the ID of the project where the forwarding policy is used. |
redirect_listener_id |
No |
String |
Specifies the ID of the listener to which requests are redirected. Note:
|
redirect_pool_id |
No |
String |
Specifies the ID of the backend server group to which the requests are forwarded. Note:
|
redirect_url |
No |
String |
Specifies the URL to which requests are forwarded. Format: protocol://host:port/path?query |
redirect_url_config |
No |
CreateRedirectUrlConfig object |
Specifies the URL to which requests are forwarded. Note:
Value format: protocol://host:port/path?query |
redirect_pools_config |
No |
Array of CreateRedirectPoolsConfig objects |
Specifies the backend server groups that the requests are forwarded to. Note: A maximum of 5 backend server groups can be configured for a forwarding policy. |
redirect_pools_sticky_session_config |
No |
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. |
|
fixed_response_config |
No |
CreateFixtedResponseConfig object |
Specifies the configuration of the page that will be returned. Note:
|
redirect_pools_extend_config |
No |
Specifies the backend server group that requests are forwarded to. Note: This parameter takes effect only when action is set to REDIRECT_TO_POOL. |
|
rules |
No |
Array of CreateL7PolicyRuleOption objects |
Lists the forwarding rules in the forwarding policy. Note:
|
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. |
host |
No |
String |
Specifies the name of the host 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. |
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. |
path |
No |
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. 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 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. 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. |
status_code |
Yes |
String |
Specifies the status code returned after the requests are redirected. The value can be 301, 302, 303, 307, or 308. |
insert_headers_config |
No |
CreateInsertHeadersConfig object |
Specifies the headers you want to write into the request that matches the forwarding rule. |
remove_headers_config |
No |
CreateRemoveHeadersConfig object |
Specifies the headers you want to remove from the request that matches the forwarding rule. |
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. |
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. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
status_code |
Yes |
String |
Specifies the fixed 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. |
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. The default value is text/plain. |
message_body |
No |
String |
Specifies the content of the response message body. |
insert_headers_config |
No |
CreateInsertHeadersConfig object |
Specifies the headers you want to write into the request that matches the forwarding rule. |
remove_headers_config |
No |
CreateRemoveHeadersConfig object |
Specifies the headers you want to remove from the request that matches the forwarding rule. |
traffic_limit_config |
No |
CreateTrafficLimitConfig object |
Specifies how requests are limited. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
rewrite_url_enable |
No |
Boolean |
Specifies whether to set rewrite_url_enable to true. |
rewrite_url_config |
No |
CreateRewriteUrlConfig object |
Specifies the URL for the backend server group that requests are forwarded to. This parameter takes effect only when action is set to REDIRECT_TO_POOL. |
insert_headers_config |
No |
CreateInsertHeadersConfig object |
Specifies the headers you want to write into the request that matches the forwarding rule. |
remove_headers_config |
No |
CreateRemoveHeadersConfig object |
Specifies the headers you want to remove from the request that matches the forwarding rule. |
traffic_limit_config |
No |
CreateTrafficLimitConfig object |
Specifies how requests are limited. |
cors_config |
No |
CreateCorsConfig object |
Specifies the CORS configurations. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
host |
No |
String |
Specifies the domain name of the host 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 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 (/). $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 $#. |
query |
No |
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. The default value is ${query}, indicating that the query string of the request will be used. 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 $#. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
configs |
Yes |
Array of CreateInsertHeaderConfig objects |
Specifies the headers you want to write into the request that matches the forwarding rule. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
Yes |
String |
Specifies the key of the header you want to write into the request that matches the forwarding rule. 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 of the header. 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, asterisk (*), and question mark (?) are also supported. The value cannot start or end with a space. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
configs |
Yes |
Array of CreateRemoveHeaderConfig objects |
Specifies the headers you want to remove from the request that matches the forwarding rule. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
Yes |
String |
Specifies the key of the header you want to remove from the request that matches the forwarding rule. 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. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
qps |
No |
Integer |
Specifies the maximum number of queries per second (QPS). The value ranges from 0 to 100000. 0 indicates that QPS is not limited. |
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 100000. 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. |
burst |
No |
Integer |
Specifies the maximum number of queries per second (QPS) from a source IP address. The value ranges from 0 to 100000. 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. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
allow_origin |
No |
Array of strings |
Specifies the origins that are allowed to access cross-origin resources through a browser. The origin can be a wildcard (*) or one or more URLs. Constraints:
|
allow_methods |
No |
Array of strings |
Specifies the HTTP methods that the specified URLs can use to access cross-origin resources. |
allow_headers |
No |
Array of strings |
Specifies the request headers that can be carried in CORS requests. |
expose_headers |
No |
Array of strings |
Specifies the headers that can be exposed. |
allow_credentials |
No |
Boolean |
Specifies whether to allow credentials in CORS requests. Value options:
|
max_age |
No |
Long |
Specifies the maximum duration a preflight request can be cached, in seconds. Value range: -1 to 172800 |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
admin_state_up |
No |
Boolean |
Specifies the administrative status of the forwarding rule. The value can only be true. |
type |
Yes |
String |
Specifies the type of the forwarding rule. Value options:
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 and QUERY_STRING, multiple forwarding rules can be created for each type. |
compare_type |
Yes |
String |
Specifies how requests are matched with the forwarding rule. Value options:
Note:
|
invert |
No |
Boolean |
Specifies whether reverse matching is supported. Value range: true or false Default value: false This parameter is unsupported. Please do not use it. |
key |
No |
String |
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 |
Specifies the value of the match item. For example, if a domain name is used for matching, value is the domain name. Note:
|
conditions |
No |
Array of CreateRuleCondition objects |
Specifies the conditions contained in a forwarding rule. Note:
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
No |
String |
Specifies the key of match item. Note:
|
value |
Yes |
String |
Specifies the value of the match item. Note:
Value ranges:
|
Response Parameters
Status code: 201
Parameter |
Type |
Description |
---|---|---|
request_id |
String |
Specifies the request ID. Note: The value is automatically generated. |
l7policy |
L7Policy object |
Specifies the forwarding policy. |
Parameter |
Type |
Description |
---|---|---|
action |
String |
Specifies where requests will be forwarded. Value options:
Note:
|
admin_state_up |
Boolean |
Specifies the administrative status of the forwarding policy. Note: The value can only be true. |
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. |
position |
Integer |
Specifies the forwarding policy priority. This parameter cannot be updated. This parameter is unsupported. Please do not use it. |
priority |
Integer |
Specifies the forwarding policy priority. A smaller value indicates a higher priority. Value ranges:
Default value options:
Note:
This parameter is supported by forwarding policies of shared load balancers. |
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.
|
redirect_pool_id |
String |
Specifies the ID of the backend server group to which the requests are forwarded. Note: This parameter is valid only when action is set to REDIRECT_TO_POOL. |
redirect_listener_id |
String |
Specifies the ID of the listener to which requests are redirected. Note:
|
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. Note:
Value format: protocol://host:port/path?query |
redirect_pools_config |
Array of RedirectPoolsConfig objects |
Specifies the backend server groups that the requests are forwarded to. Note: A maximum of 5 backend server groups can be configured for a forwarding policy. |
redirect_pools_sticky_session_config |
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 requests are forwarded to. Note: This parameter takes effect only when action is set to REDIRECT_TO_POOL. |
fixed_response_config |
FixtedResponseConfig object |
Specifies the configuration of the page that will be returned. Note:
|
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. |
enterprise_project_id |
String |
Specifies the ID of the enterprise project. |
Parameter |
Type |
Description |
---|---|---|
protocol |
String |
Specifies the protocol for redirection. The value can be HTTP, HTTPS, or ${protocol}. ${protocol} indicates that the protocol of the request will be used. |
host |
String |
Specifies the name of the host 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. |
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. |
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. 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. 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. |
status_code |
String |
Specifies the status code returned after the requests are redirected. The value can be 301, 302, 303, 307, or 308. |
insert_headers_config |
InsertHeadersConfig object |
Specifies the headers you want to write into the request that matches the forwarding rule. |
remove_headers_config |
RemoveHeadersConfig object |
Specifies the headers you want to remove from the request that matches the forwarding rule. |
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. |
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. |
timeout |
Integer |
Specifies the duration that a session persists. The value ranges from 1 to 1440 (default), in minutes. |
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 takes effect only 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 forwarding rule. |
remove_headers_config |
RemoveHeadersConfig object |
Specifies the headers you want to remove from the request that matches the forwarding rule. |
traffic_limit_config |
TrafficLimitConfig object |
Specifies how requests are limited. |
cors_config |
CorsConfig object |
Specifies the CORS configurations. |
Parameter |
Type |
Description |
---|---|---|
host |
String |
Specifies the domain name of the host 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 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 (/). $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 $#. |
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. The default value is ${query}, indicating that the query string of the request will be used. 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 $#. |
Parameter |
Type |
Description |
---|---|---|
allow_origin |
Array of strings |
Specifies the origins that are allowed to access cross-origin resources through a browser. The origin can be a wildcard (*) or one or more URLs. Constraints:
|
allow_methods |
Array of strings |
Specifies the HTTP methods that the specified URLs can use to access cross-origin resources. |
allow_headers |
Array of strings |
Specifies the request headers that can be carried in CORS requests. |
expose_headers |
Array of strings |
Specifies the headers that can be exposed. |
allow_credentials |
Boolean |
Specifies whether to allow credentials in CORS requests. Value options:
|
max_age |
Long |
Specifies the maximum duration a preflight request can be cached, in seconds. Value range: -1 to 172800 |
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. |
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. |
message_body |
String |
Specifies the content of the response message body. |
insert_headers_config |
InsertHeadersConfig object |
Specifies the headers you want to write into the request that matches the forwarding rule. |
remove_headers_config |
RemoveHeadersConfig object |
Specifies the headers you want to remove from the request that matches the forwarding rule. |
traffic_limit_config |
TrafficLimitConfig object |
Specifies how requests are limited. |
Parameter |
Type |
Description |
---|---|---|
configs |
Array of InsertHeaderConfig objects |
Specifies the headers you want to write into the request that matches the forwarding rule. |
Parameter |
Type |
Description |
---|---|---|
key |
String |
Specifies the key of the header you want to write into the request that matches the forwarding rule. 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 of the header. 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. ASCII codes 32 through 127 printable characters, asterisk (*), and question mark (?) are also supported. The value cannot start or end with a space. |
Parameter |
Type |
Description |
---|---|---|
configs |
Array of RemoveHeaderConfig objects |
Specifies the headers you want to remove from the request that matches the forwarding rule. |
Parameter |
Type |
Description |
---|---|---|
key |
String |
Specifies the key of the header you want to remove from the request that matches the forwarding rule. 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. |
Parameter |
Type |
Description |
---|---|---|
qps |
Integer |
Specifies the maximum number of queries per second (QPS). The value ranges from 0 to 100000. 0 indicates that QPS is not limited. |
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 100000. 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. |
burst |
Integer |
Specifies the maximum number of queries per second (QPS) from a source IP address. The value ranges from 0 to 100000. 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. |
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
Normal response to POST requests.
{ "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" } }
SDK Sample Code
The SDK sample code is as follows.
Creating a redirection for a listener.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.elb.v3.region.ElbRegion; import com.huaweicloud.sdk.elb.v3.*; import com.huaweicloud.sdk.elb.v3.model.*; public class CreateL7PolicySolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); ElbClient client = ElbClient.newBuilder() .withCredential(auth) .withRegion(ElbRegion.valueOf("<YOUR REGION>")) .build(); CreateL7PolicyRequest request = new CreateL7PolicyRequest(); CreateL7PolicyRequestBody body = new CreateL7PolicyRequestBody(); CreateL7PolicyOption l7policybody = new CreateL7PolicyOption(); l7policybody.withAction("REDIRECT_TO_LISTENER") .withListenerId("e2220d2a-3faf-44f3-8cd6-0c42952bd0ab") .withRedirectListenerId("48a97732-449e-4aab-b561-828d29e45050"); body.withL7policy(l7policybody); request.withBody(body); try { CreateL7PolicyResponse response = client.createL7Policy(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
Creating a redirection for a listener.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkelb.v3.region.elb_region import ElbRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkelb.v3 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = ElbClient.new_builder() \ .with_credentials(credentials) \ .with_region(ElbRegion.value_of("<YOUR REGION>")) \ .build() try: request = CreateL7PolicyRequest() l7policybody = CreateL7PolicyOption( action="REDIRECT_TO_LISTENER", listener_id="e2220d2a-3faf-44f3-8cd6-0c42952bd0ab", redirect_listener_id="48a97732-449e-4aab-b561-828d29e45050" ) request.body = CreateL7PolicyRequestBody( l7policy=l7policybody ) response = client.create_l7_policy(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Creating a redirection for a listener.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" elb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := elb.NewElbClient( elb.ElbClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CreateL7PolicyRequest{} redirectListenerIdL7policy:= "48a97732-449e-4aab-b561-828d29e45050" l7policybody := &model.CreateL7PolicyOption{ Action: "REDIRECT_TO_LISTENER", ListenerId: "e2220d2a-3faf-44f3-8cd6-0c42952bd0ab", RedirectListenerId: &redirectListenerIdL7policy, } request.Body = &model.CreateL7PolicyRequestBody{ L7policy: l7policybody, } response, err := client.CreateL7Policy(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Creating a redirection for a listener.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.elb.v3.region.ElbRegion; import com.huaweicloud.sdk.elb.v3.*; import com.huaweicloud.sdk.elb.v3.model.*; public class CreateL7PolicySolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); ElbClient client = ElbClient.newBuilder() .withCredential(auth) .withRegion(ElbRegion.valueOf("<YOUR REGION>")) .build(); CreateL7PolicyRequest request = new CreateL7PolicyRequest(); CreateL7PolicyRequestBody body = new CreateL7PolicyRequestBody(); CreateL7PolicyOption l7policybody = new CreateL7PolicyOption(); l7policybody.withAction("REDIRECT_TO_LISTENER") .withListenerId("e2220d2a-3faf-44f3-8cd6-0c42952bd0ab") .withRedirectListenerId("48a97732-449e-4aab-b561-828d29e45050"); body.withL7policy(l7policybody); request.withBody(body); try { CreateL7PolicyResponse response = client.createL7Policy(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
Creating a redirection for a listener.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkelb.v3.region.elb_region import ElbRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkelb.v3 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = ElbClient.new_builder() \ .with_credentials(credentials) \ .with_region(ElbRegion.value_of("<YOUR REGION>")) \ .build() try: request = CreateL7PolicyRequest() l7policybody = CreateL7PolicyOption( action="REDIRECT_TO_LISTENER", listener_id="e2220d2a-3faf-44f3-8cd6-0c42952bd0ab", redirect_listener_id="48a97732-449e-4aab-b561-828d29e45050" ) request.body = CreateL7PolicyRequestBody( l7policy=l7policybody ) response = client.create_l7_policy(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Creating a redirection for a listener.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" elb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := elb.NewElbClient( elb.ElbClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CreateL7PolicyRequest{} redirectListenerIdL7policy:= "48a97732-449e-4aab-b561-828d29e45050" l7policybody := &model.CreateL7PolicyOption{ Action: "REDIRECT_TO_LISTENER", ListenerId: "e2220d2a-3faf-44f3-8cd6-0c42952bd0ab", RedirectListenerId: &redirectListenerIdL7policy, } request.Body = &model.CreateL7PolicyRequestBody{ L7policy: l7policybody, } response, err := client.CreateL7Policy(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
Status Code |
Description |
---|---|
201 |
Normal response to POST requests. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot