Forwarding Policy
Scenarios
You can configure forwarding policies for HTTP or HTTPS listeners to forward requests to different backend server groups based on domain names or paths.
This is suitable when requests of services such as videos, images, audios, and texts need to be forwarded to different backend servers.
A forwarding policy consists of two parts: forwarding rule and action.
- A forwarding rule can be a domain name or a path.
- HTTP listeners can forward requests to a backend server group or redirect requests to another listener.
- HTTPS listeners can forward requests to a backend server group.
How Requests Are Matched
- After receiving a request, the load balancer attempts to find a matching forwarding policy based on the domain name or URL in the request:
- If a match is found, the request is forwarded to the backend server group you select or create when you add the forwarding policy.
- If no match is found, the request is forwarded to the default backend server group (that is specified when the listener is created).
- Matching priority:
- Forwarding rule priorities are independent of each other regardless of domain names. When a request matches both a domain name-based rule and a path-based rule, the domain named-based rule is matched first.
- Path-based forwarding rules are applied in the following order of priority: an exact match rule, a prefix match rule, and a regular expression match rule. For multiple matches of the same type, only the longest path rule will be applied.
Request |
Forwarding Policy |
Forwarding Rule |
Specified Value |
---|---|---|---|
www.elb.com/test |
1 |
Path |
/test |
2 |
Domain name |
www.elb.com |
In this example, although request www.elb.com/test matches both forwarding policies, it is routed based on forwarding policy 2 because domain named-based forwarding rules are applied first.
Notes and Constraints
- Forwarding policies can be configured only for HTTP and HTTPS listeners.
- Forwarding policies must be unique.
- 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.
- When you add a forwarding policy, note the following:
- The path in a forwarding rule cannot contain query strings. For example, if the path is set to /path/resource?name=value, the forwarding policy is invalid.
- Each path must exist on the backend server. If the path does not exist, the backend server will return 404 Not Found.
- In the regular expression match, the characters are matched sequentially, and the matching ends when any rule is matched. Matching rules cannot overlap with each other.
- A path cannot be configured for two forwarding policies.
- A domain name cannot exceed 100 characters.
If you add a forwarding policy that is the same as an existing one by calling an API, there will be a conflict. Even if you delete the existing forwarding policy, the new forwarding policy is still unavailable. Delete the newly-added forwarding policy and add a different one.
Adding a Forwarding Policy
- Go to the load balancer list page.
- On the displayed page, locate the load balancer you want to add forwarding policies for and click its name.
- On the Listeners tab, add a forwarding policy in either of the following ways:
- Locate the target listener and click Add/Edit Forwarding Policy in the Forwarding Policies column.
- Locate the target listener, click its name, and click the Forwarding Policies tab.
- Click Add Forwarding Policy. Configure the parameters based on Table 2.
- After the configuration is complete, click Save.
Path Matching Examples
The following table lists how a path is matched, and Figure 1 shows how a request is forwarded to a backend server group.
URL Matching Rule |
URL in the Request |
Specified Path |
|||
---|---|---|---|---|---|
N/A |
N/A |
/elb/index.html |
/elb |
/elb[^\s]* |
/index.html |
Exact match |
/elb/index.html |
√ |
N/A |
N/A |
N/A |
Prefix match |
√ |
√ |
N/A |
N/A |
|
Regular expression match |
√ |
N/A |
√ |
N/A |
In this figure, the system first searches for an exact match of the request URL (/elb_gls/glossary.html). If there is no exact match, the system searches for a prefix match. If a match is found, the request is forwarded to backend server group 2 even if a regular expression match is also found, because the prefix match has a higher priority.
Modifying a Forwarding Policy
- Go to the load balancer list page.
- On the displayed page, locate the load balancer whose forwarding policies you want to modify and click its name.
- Click Listeners, locate the listener, and click its name.
- On the Forwarding Policies tab, select the forwarding policy, and click Edit.
- Modify the parameters and click Save.
Deleting a Forwarding Policy
- Go to the load balancer list page.
- On the displayed page, locate the load balancer whose forwarding policies you want to delete and click its name.
- Click Listeners, locate the listener, and click its name.
- On the Forwarding Policies tab, select the forwarding policy, and click Delete on the top right.
- In the displayed dialog box, click OK.
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