Reviewed-by: Hajba, László Antal <laszlo-antal.hajba@t-systems.com> Co-authored-by: zhoumeng <zhoumeng35@huawei.com> Co-committed-by: zhoumeng <zhoumeng35@huawei.com>
40 KiB
Configuring Advanced Forwarding
Scenarios
You can add advanced forwarding policies to HTTP or HTTPS listeners of dedicated load balancers to route requests more specifically.
- Dedicated load balancers support the following types of forwarding rules: domain name, URL, HTTP request method, HTTP header, query string, and CIDR block (source IP addresses). For details, see Forwarding Rule Types.
- There are four types of actions: forward to a backend server group, redirect to another listener, redirect to another URL, and return a specific response body. For details, see Action Types.
- Wildcard domain names are allowed.
- Multiple forwarding rules can be configured in a single forwarding policy.
- Forwarding policies can be sorted based on their priorities.
Constraints and Limitations
- Advanced forwarding cannot be disabled once enabled.
- A maximum of 100 forwarding policies can be configured for a listener. If the number of forwarding policies exceeds the quota, the excess forwarding policies will not be applied.
- An advanced forwarding policy can contain a maximum of 10 conditions.
Enabling Advanced Forwarding
- Log in to the management console.
- In the upper left corner of the page, click
and select the desired region and project.
- Click
in the upper left corner to display Service List and choose Network > Elastic Load Balancing.
- Locate the load balancer and click its name.
- Click Listeners, locate the listener, and click its name.
- In the Basic Information tab page of the listener in the right pane, click Enable next to Advanced Forwarding.
- Click OK.
Adding an Advanced Forwarding Policy
- Log in to the management console.
- In the upper left corner of the page, click
and select the desired region and project.
- Click
in the upper left corner to display Service List and choose Network > Elastic Load Balancing.
- Locate the load balancer and click its name.
- Click Listeners, locate the listener, and click its name.
- Click
on the right of the listener name and select Configure Forwarding Policy.
Alternatively, click Forwarding Policies on the right of the page.
- On the Forwarding Policies tab page, click Add Forwarding Policy.
Configure the parameters based on Table 1.
- Click Save.
Parameter |
Description |
Example Value |
|
---|---|---|---|
Forwarding Rule |
Domain name |
Route requests based on the domain name. Exact match domains and wildcard domains are supported.
|
www.example.com |
URL |
Route requests based on the URLs.
|
Request URL: /login.php
|
|
HTTP request method |
Route requests based on any HTTP method. The following methods are available: GET, POST, PUT, DELETE, PATCH, HEAD, and OPTIONS. You can configure multiple request methods in a forwarding policy. |
GET |
|
HTTP header |
Route requests based on the HTTP header. An HTTP header consists of a key and one or more values. You need to configure the key and values separately.
|
|
|
Query string |
Route requests based on the query string. A query string consists of a key and one or more values. You need to set the key and values separately.
|
|
|
CIDR block |
Route requests based on the source IP addresses. |
192.168.1.0/24 |
|
Action |
Forward to a backend server group |
Requests are forwarded to the specified backend server group. |
Forward to a backend server group |
Redirect to another listener |
Forwards requests from the HTTP listener to an HTTPS listener. NOTE:
If you select Redirect to another listener and create a redirect for the current listener, this listener will not route requests and will redirect the requests to the specified HTTPS listener, but access control configured for the listener will still take effect. For example, if you configure a redirect for an HTTP listener, HTTP requests to access a web page will be redirected to the HTTPS listener you select and handled by the backend servers associated with the HTTPS listener. As a result, the clients access the web page over HTTPS. |
- |
|
Redirect to another URL |
Requests are redirected to the configured URL. When clients access website A, the load balancer returns 302 or any other 3xx status code and automatically redirects the clients to website B. You can custom the redirection URL that will be returned to the clients. A URL consists of the following parameters:
NOTE:
Specify either the above parameters or a combination of them. |
Protocol: HTTP Domain name: www.example1.com Port: 8081 Path: /index.html Query string: locale=en-us HTTP status code: 301 |
|
Return a specific response body |
Load balancers return a fixed response to the clients. You can custom the status code and response body that load balancers directly return to the clients without the need to route the requests to backend servers. A response body consists of the following parameters:
|
HTTP Status Code: 200 Content-Type: text/plain Message Body: The server can be accessed normally. |
Sorting Forwarding Policies
Multiple forwarding policies can be sorted to set their priorities.
- Log in to the management console.
- In the upper left corner of the page, click
and select the desired region and project.
- Click
in the upper left corner to display Service List and choose Network > Elastic Load Balancing.
- Locate the load balancer and click its name.
- Click Listeners, locate the listener, and click its name.
- Click
on the right of the listener name and select Configure Forwarding Policy.
Alternatively, click Forwarding Policies in the right pane.
- On the Forwarding Policies tab page, click Sort.
- Click Up or Down in the upper right corner of the forwarding policy.
- Click Save.
URL Matching Examples
Table 2 shows how URLs configured in the forwarding policies match the URLs in the requests.
Request URL |
Forwarding Policy |
URL in the Forwarding Policy |
Matching Mode |
Forwarding Policy Priority |
Forward to a backend server group |
---|---|---|---|---|---|
/elb/abc.html |
Forwarding policy 01 |
/elb/abc.html |
Prefix match |
1 |
Backend server group 01 |
Forwarding policy 02 |
/elb |
Prefix match |
2 |
Backend server group 02 |
|
/exa/index.html |
Forwarding policy 03 |
/exa[^\s]* |
Regular expression match |
3 |
Backend server group 03 |
Forwarding policy 04 |
/exa/index.html |
Regular expression match |
4 |
Backend server group 04 |
|
/mpl/index.html |
Forwarding policy 05 |
/mpl/index.html |
Exact match |
5 |
Backend server group 05 |
URLs are matched as follows:
- When the request URL is /elb/abc.html, it matches both forwarding policy 01 and forwarding policy 02. However, the priority of forwarding policy 01 is higher than that of forwarding policy 02. Forwarding policy 01 is used, and requests are forwarded to backend server group 01.
- When the request URL is /exa/index.html, it matches both forwarding policy 03 and forwarding policy 04. However, the priority of forwarding policy 03 is higher than that of forwarding policy 04. Forwarding policy 03 is used, and requests are forwarded to backend server group 03.
- If the request URL is /mpl/index.html, it matches forwarding policy 05 exactly, and requests are forwarded to backend server group 05.
Modifying a Forwarding Policy
- Log in to the management console.
- In the upper left corner of the page, click
and select the desired region and project.
- Click
in the upper left corner to display Service List and choose Network > Elastic Load Balancing.
- Locate the load balancer and click its name.
- Click Listeners, locate the listener, and click its name.
- Click
on the right of the listener name and select Configure Forwarding Policy.
Alternatively, click Forwarding Policies in the right pane.
- On the Forwarding Policies tab page, select the forwarding policy you want to modify and click Edit.
- Modify the parameters and click Save.
Deleting a Forwarding Policy
You can delete a forwarding policy if you no longer need it.
Deleted forwarding policies cannot be recovered.
- Log in to the management console.
- In the upper left corner of the page, click
and select the desired region and project.
- Click
in the upper left corner to display Service List and choose Network > Elastic Load Balancing.
- Locate the load balancer and click its name.
- Click Listeners, locate the listener, and click its name.
- Click
on the right of the listener name and select Configure Forwarding Policy.
Alternatively, click Forwarding Policies in the right pane.
- On the Forwarding Policies tab page, select the forwarding policy you want to delete and click Delete.
- In the displayed dialog box, click Yes.