Forwarding Policy (Dedicated Load Balancers)

If advanced forwarding is not enabled, perform the following operations to add forwarding policies to HTTP or HTTPS listeners of dedicated load balancers.

Scenarios

You can add forwarding policies to HTTP or HTTPS listeners to forward requests to different backend server groups based on domain names or URLs.

This is suited for applications that are deployed on multiple backend servers and provide multiple types of services such as videos, images, audios, and texts.

A forwarding policy consists of one or more forwarding rules and an action.

  • There are two types of forwarding rules: domain name and URL.

  • There are two types of actions: forward to a backend server group and redirect to another listener (only HTTP listeners).

Constraints and Limitations

  • Forwarding policies can be added only to HTTP and HTTPS listeners.

  • Redirection to another listener is supported only by HTTP 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:

    • Each URL path must exist on the backend server. If the path does not exist, the backend server will return 404 Not Found.

    • A URL path cannot be configured for two forwarding policies.

    • In the regular expression match, the characters are matched sequentially, and matching ends when any rule is successfully matched. Matching rules cannot overlap with each other.

    • A domain name cannot exceed 100 characters.

  • After you add a forwarding policy, the load balancer forwards requests based on the specified domain name or URL:

    • If the domain name or URL in a request matches the value specified in the forwarding policy, the request is forwarded to the backend server group you select when you add the forwarding policy.

    • If the domain name or URL in a request does not match the value specified in the forwarding policy, the request is forwarded to the default backend server group of the listener.

Adding a Forwarding Policy

  1. Log in to the management console.

  2. In the upper left corner of the page, click image1 and select the desired region and project.

  3. Hover on image2 in the upper left corner to display Service List and choose Network > Elastic Load Balancing.

  4. Locate the load balancer and click its name.

  5. Click Listeners, locate the listener, and click its name.

  6. Click image3 on the right of the listener name and select Configure Forwarding Policy.

    Alternatively, click Forwarding Policies on the right of the page.

  7. On the Forwarding Policies tab page, click Add Forwarding Policy. Configure the parameters based on Table 1.

  8. Click Save.

Table 1 Forwarding policy parameters

Parameter

Description

Example Value

Forwarding Rule

Domain name

Specifies the domain name used for forwarding requests. The domain name in the request must exactly match that in the forwarding policy.

You need to specify either a domain name or URL.

Note

Advanced forwarding policies support wildcard domain names. For details, see Advanced Forwarding.

www.test.com

URL

Specifies the URL used for forwarding requests. There are three URL matching rules:

  • Exact match

    The request URL must exactly match the value specified in the forwarding policy.

  • Prefix match

    The requested URL starts with the specified URL string.

  • Regular expression match

    The requested URL matches the specified URL string based on the regular expression.

/login.php

Action

Forward to a backend server group

If the request matches the configured forwarding rule, the request is forwarded to the specified backend server group.

Forward to a backend server group

Redirect to another listener

If the request matches the configured forwarding rule, the request is redirected to the specified HTTPS listener.

This action can be configured only for HTTP listeners.

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.

-

Backend Server Group

Select a backend server group that will receive requests from the load balancer.

This parameter is mandatory when you set Action to Forward to a backend server group.

-

Listener

Select an HTTPS listener that will receive requests redirected from the current HTTP listener.

This parameter is mandatory when Action is set to Redirect to another listener.

-

URL Matching Example

Table 2 shows an example of URL matching.

Table 2 URL matching

URL Matching Rule

URL

URL in the Forwarding Policy

-

-

/elb/index.html

/elb

/elb[^\s]*

/index.html

Exact match

/elb/index.html

Y

-

-

-

Prefix match

Y

Y

-

-

Regular expression match

Y

-

Y

-

Figure 1 shows an example of how a URL is matched and requests are forwarded.

**Figure 1** Request forwarding

Figure 1 Request forwarding

In this example, the request URL /elb_gls/glossary.html is searched using the Exact match rule first. If no precisely matched URL is found, the Prefix match rule is used. If a URL matches the prefix of the request URL, the request is forwarded to backend server group 2 based on the URL. Although the request URL matches rule 3 in Regular expression match, the request is forwarded to backend server group 2 because of the higher priority of Prefix match.

Modifying a Forwarding Policy

  1. Log in to the management console.

  2. In the upper left corner of the page, click image4 and select the desired region and project.

  3. Hover on image5 in the upper left corner to display Service List and choose Network > Elastic Load Balancing.

  4. Locate the load balancer and click its name.

  5. Click Listeners, locate the listener, and click its name.

  6. Click image6 on the right of the listener name and select Configure Forwarding Policy.

    Alternatively, click Forwarding Policies in the right pane.

  7. On the Forwarding Policies tab page, select the forwarding policy you want to modify and click Edit.

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

  1. Log in to the management console.

  2. In the upper left corner of the page, click image7 and select the desired region and project.

  3. Hover on image8 in the upper left corner to display Service List and choose Network > Elastic Load Balancing.

  4. Locate the load balancer and click its name.

  5. Click Listeners, locate the listener, and click its name.

  6. Click image9 on the right of the listener name and select Configure Forwarding Policy.

    Alternatively, click Forwarding Policies in the right pane.

  7. On the Forwarding Policies tab page, select the forwarding policy you want to delete and click Delete.

  8. In the displayed dialog box, click Yes.