Forwarding Policy (Dedicated Load Balancer)

Scenarios

Like shared load balancers, dedicated load balancers can forward requests based on domain names or URLs. Currently, you can add forwarding policies to HTTP and HTTPS listeners.

You can add a maximum of 500 forwarding policies to a listener. With forwarding policies, requests for videos, images, audio, or text are forwarded to different backend server groups, making it easier to allocate resources.

When you add a forwarding policy, note the following:

  • Each URL path exists on the backend servers in the backend server group to which requests are forwarded. Otherwise, the backend servers will return a 404 error.
  • The same path cannot be configured for two forwarding policies.
  • In regular expression match, the characters are matched sequentially, and matching ends when any rule is successfully matched. Matching rules cannot overlap with each other.

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 forwarding policy, the request is forwarded to the backend server group you configured when you added the forwarding policy.
  • If the domain name or URL in a request does not match the forwarding policy, the request is forwarded to the default backend server group associated with the listener.

Adding a Forwarding Policy

  1. Log in to the management console.
  2. In the upper left corner of the page, click and select the desired region and project.
  3. Click Service List. Under Network, click Elastic Load Balance.
  4. Locate the load balancer and click its name.
  5. Click Listeners, locate the listener, and click its name.
  6. Click 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, click Add Forwarding Policy.

    Set the parameters based on Table 1.

  8. After the configuration is complete, click Save.
Table 1 Forwarding policy parameters

Parameter

Description

Example Value

Domain Name

Specifies the domain name for triggering the forwarding. Only exact match domain names are supported.

Note that you must specify either a domain name or URL.

NOTE:

Wildcard domain names can be used to forward requests. For details, see Advanced Forwarding.

www.test.com

URL

Enter a URL for triggering the forwarding policy.

/login.php

Action

Select Forward to another backend server group or Redirect to another listener.

Forward to another backend server group

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

NOTE:

If you select Redirect to another listener and create a redirect for the current listener, the configuration of this listener will become invalid except for access control.

-

Advanced Forwarding

Dedicated load balancers support advanced forwarding policies. After you enable advanced forwarding, you can sort the forwarding policies and set forwarding rules including wildcard domain name, HTTP request method, URL, HTTP header, query string, and CIDR block. You can also choose to redirect the requests to another URL and make backend servers return a fixed message body.

  • Fixed response: You can custom the status code and response body that the load balancer can directly return to the clients if the load balancer does not route the requests to backend servers.
  • Redirect to another 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 and the status code that will be returned to the clients.

You cannot disable advanced forwarding after you have enabled it.

  1. Log in to the management console.
  2. In the upper left corner of the page, click and select the desired region and project.
  3. Click Service List. Under Network, click Elastic Load Balance.
  4. Locate the load balancer and click its name.
  5. Click Listeners, locate the listener, and click its name.
  6. In the Basic Information area of the listener in the right pane, click Enable Advanced Forwarding.
  7. Click OK.

URL Matching Example

The following table lists how a URL is matched, and Figure 1 shows how a request is forwarded to a backend server group.

Table 2 URL matching

URL Matching Rule

URL

Preset URL

-

-

/elb/index.html

/elb

/elb[^\s]*

/index.html

Exact match

/elb/index.html

√

-

-

-

Prefix match

√

√

-

-

Regular expression match

√

-

√

-

Figure 1 Request forwarding

In this figure, the system first searches the requested URL (/elb_gls/glossary.html) using the Exact match rule. If there is no exactly matched URL, the Prefix match rule is used. If the start string of the requested URL matches that of the specified URL, the request is forwarded to backend server group 2 even if the requested URL also matches rule 3 (Regular expression match) because Prefix match has a higher priority.

Modifying a Forwarding Policy

  1. Log in to the management console.
  2. In the upper left corner of the page, click and select the desired region and project.
  3. Click Service List. Under Network, click Elastic Load Balance.
  4. Locate the load balancer and click its name.
  5. Click Listeners, locate the listener, and click its name.
  6. Click 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 and select the desired region and project.
  3. Click Service List. Under Network, click Elastic Load Balance.
  4. Locate the load balancer and click its name.
  5. Click Listeners, locate the listener, and click its name.
  6. Click 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. Click Yes.