هذه الصفحة غير متوفرة حاليًا بلغتك المحلية. نحن نعمل جاهدين على إضافة المزيد من اللغات. شاكرين تفهمك ودعمك المستمر لنا.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Adding a Forwarding Policy

Updated on 2025-02-24 GMT+08:00

Function

This API is used to add a forwarding policy. The listener and forwarding policy determine how traffic is forwarded to backend servers.

  • By matching the URL or domain name specified in the forwarding policy when action is set to REDIRECT_TO_POOL, the load balancer distributes the traffic to backend servers in a specific backend server group.
  • When action is set to REDIRECT_TO_LISTENER, the HTTP listener is redirected to an HTTPS listener, and requests are routed by the HTTPS listener.

Constraints

Currently, only redirects from an HTTP listener to an HTTPS listener are supported. When action is set to REDIRECT_TO_LISTENER, the listener specified by listener_id can only be an HTTP listener, and the listener specified by redirect_listener_id can only be an HTTPS listener.

The load balancer of the HTTPS listener to which traffic is redirected must be the same as that of the HTTP listener.

URI

POST /v2/{project_id}/elb/l7policies

Table 1 Parameter description

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the project ID.

Request

Table 2 Parameter description

Parameter

Mandatory

Type

Description

l7policy

Yes

L7policy object

Specifies the forwarding policy. For details, see Table 3.

Table 3 l7policy parameter description

Parameter

Mandatory

Type

Description

tenant_id

No

String

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

The value must be the same as the value of project_id in the token.

The value contains a maximum of 255 characters.

name

No

String

Specifies the forwarding policy name.

The value contains a maximum of 255 characters.

admin_state_up

No

Boolean

Specifies the administrative status of the forwarding policy. The value can only be true.

description

No

String

Provides supplementary information about the forwarding policy.

The value contains a maximum of 255 characters.

listener_id

Yes

String

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

  • When action is set to REDIRECT_TO_POOL, forwarding policies can be added to a listener with protocol set to HTTP or TERMINATED_HTTPS.
  • When action is set to REDIRECT_TO_LISTENER, forwarding policies can be added to a listener with protocol set to HTTP.

action

Yes

String

Specifies whether requests are forwarded to another backend server group or redirected to an HTTPS listener.

The value can be:

  • REDIRECT_TO_POOL: Requests are forwarded to the backend server group specified by redirect_pool_id.
  • REDIRECT_TO_LISTENER: Requests are redirected from the HTTP listener specified by listener_id to the HTTPS listener specified by redirect_listener_id.

redirect_pool_id

No

String

Specifies the ID of the backend server group to which traffic is forwarded. The default value is null.

This parameter is mandatory when action is set to REDIRECT_TO_POOL.

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

The backend server group must meet the following requirements:

  • Cannot be the default backend server group of the listener.
  • Cannot be the backend server group used by forwarding policies of other listeners.

redirect_listener_id

No

String

Specifies the ID of the listener to which the traffic is redirected. The default value is null.

This parameter is mandatory when action is set to REDIRECT_TO_LISTENER.

This parameter cannot be specified when action is set to REDIRECT_TO_POOL. The listener must meet the following requirements:

  • Can only be an HTTPS listener.
  • Can only be a listener of the same load balancer.

redirect_url

No

String

Specifies the URL to which traffic is redirected. The default value is null.

This parameter is reserved.

The value contains a maximum of 255 characters.

position

No

Integer

Specifies the forwarding priority. The value ranges from 1 to 100. The default value is 100.

This parameter is reserved.

rules

No

Array of Rules objects

Lists the forwarding rules of the forwarding policy. For details, see Table 4.

The list contains a maximum of two rules, and the type parameter of each rule must be unique.

Table 4 rules parameter description

Parameter

Type

Mandatory

Description

admin_state_up

Boolean

No

Specifies the administrative status of the forwarding rule. The value can only be true.

type

String

Yes

Specifies the match type of a forwarding rule.

The value can be:

  • HOST_NAME: matches the domain name in the request.
  • PATH: matches the path in the request.

The match type of forwarding rules in a forwarding policy must be unique.

compare_type

String

Yes

Specifies the match mode. The options are as follows:

When type is set to HOST_NAME, the value of this parameter can only be the following:

  • EQUAL_TO: indicates exact match.

When type is set to PATH, the value of this parameter can be one of the following:

  • REGEX: indicates regular expression match.
  • STARTS_WITH: indicates prefix match.
  • EQUAL_TO: indicates exact match.

invert

Boolean

No

Specifies whether reverse matching is supported.

The value can be true or false. The default value is false.

This parameter is reserved.

key

String

No

Specifies the key of the match content. The default value is null.

This parameter is reserved.

value

String

Yes

Specifies the value of the match content. The value cannot contain spaces.

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

Response

Table 5 Parameter description

Parameter

Type

Description

l7policy

L7policy object

Specifies the forwarding policy. For details, see Table 6.

Table 6 l7policy parameter description

Parameter

Type

Description

id

String

Specifies the forwarding policy ID.

tenant_id

String

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

name

String

Specifies the forwarding policy name.

admin_state_up

Boolean

Specifies the administrative status of the forwarding policy. The value can only be true.

description

String

Provides supplementary information about the forwarding policy.

listener_id

String

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

action

String

Specifies whether requests are forwarded to another backend server group or redirected to an HTTPS listener.

The value can be:

  • REDIRECT_TO_POOL: Requests are forwarded to the backend server group specified by redirect_pool_id.
  • REDIRECT_TO_LISTENER: Requests are redirected from the HTTP listener specified by listener_id to the HTTPS listener specified by redirect_listener_id.

redirect_pool_id

String

Specifies the ID of the backend server group to which traffic is forwarded.

redirect_listener_id

String

Specifies the ID of the listener to which the traffic is redirected.

redirect_url

String

Specifies the URL to which traffic is redirected.

This parameter is reserved.

rules

Array of Rules objects

Lists the forwarding rules of the forwarding policy. For details, see Table 7.

position

Integer

Specifies the forwarding priority. The value ranges from 1 to 100. The default value is 100.

This parameter is reserved.

provisioning_status

String

This parameter is reserved, and its value can only be ACTIVE.

It specifies the provisioning status of the forwarding policy.

Table 7 rules parameter description

Parameter

Type

Description

id

String

Specifies the ID of the associated forwarding rule.

Example Request

  • Example request 1: Adding a forwarding policy
    POST https://{Endpoint}/v2/573d73c9f90e48d0bddfa0eb202b25c2/elb/l7policies
    
    {
        "l7policy": {
            "name": "niubiao_yaqing_api-2", 
            "listener_id": "3e24a3ca-11e5-4aa3-abd4-61ba0a8a18f1", 
            "action": "REDIRECT_TO_POOL", 
            "redirect_pool_id": "6460f13a-76de-43c7-b776-4fefc06a676e", 
            "rules": [
                {
                    "type": "PATH", 
                    "compare_type": "EQUAL_TO", 
                    "value": "/test"
                }, 
                {
                    "type": "HOST_NAME", 
                    "compare_type": "EQUAL_TO", 
                    "value": "www.test.com"
                }
            ]
        }
    }
  • Example request 2: Creating a redirect
    POST https://{Endpoint}/v2/573d73c9f90e48d0bddfa0eb202b25c2/elb/l7policies
    
    {
        "l7policy": {
            "action": "REDIRECT_TO_LISTENER", 
            "listener_id": "4ef8553e-9ef7-4859-a42d-919feaf89d60", 
            "redirect_listener_id": "3ee10199-a7b4-4784-93cd-857afe9d0890", 
            "name": "redirect-test"
        }
    }

Example Response

  • Example response 1
    {
        "l7policy": {
            "redirect_pool_id": "6460f13a-76de-43c7-b776-4fefc06a676e", 
            "description": "", 
            "admin_state_up": true, 
            "rules": [
                {
                    "id": "742600d9-2a14-4808-af69-336883dbb590"
                }, 
                {
                    "id": "3251ed77-0d52-412b-9310-733636bb3fbf"
                }
            ], 
            "tenant_id": "573d73c9f90e48d0bddfa0eb202b25c2", 
            "listener_id": "3e24a3ca-11e5-4aa3-abd4-61ba0a8a18f1", 
            "redirect_url": null, 
            "redirect_listener_id": null, 
            "action": "REDIRECT_TO_POOL", 
            "position": 100, 
            "provisioning_status": "ACTIVE", 
     
            "id": "65d6e115-f179-4bcd-9bbb-1484e5f8ee81", 
            "name": "niubiao_yaqing-_api-2"
        }
    }
  • Example response 2
    {
        "l7policy": {
            "redirect_pool_id": null, 
            "description": "", 
            "admin_state_up": true, 
            "rules": [ ], 
            "tenant_id": "573d73c9f90e48d0bddfa0eb202b25c2", 
            "listener_id": "4ef8553e-9ef7-4859-a42d-919feaf89d60", 
            "redirect_url": null, 
            "redirect_listener_id": "3ee10199-a7b4-4784-93cd-857afe9d0890", 
            "action": "REDIRECT_TO_LISTENER", 
            "position": 100, 
            "provisioning_status": "ACTIVE", 
     
            "id": "bc4e4338-480f-4a98-8245-5bb1964f0e1d", 
            "name": "redirect-test"
        }
    }

Status Code

For details, see Status Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback