edit-icon download-icon

How to forward same-domain requests to different servers

Last Updated: Nov 21, 2017

In this case, we use four ECSs deployed with Nginx servers as the example to demonstrate how to configure forwarding rules specified by domain name and URL, so as to fulfill traffic forwarding as shown in the following table.

Frontend requestForward traffic to
www.aaa.com/tom Server SLB_tom1 and server SBL_tom2
www.aaa.com/jerry Server SLB_jerry1 and server SBL_jerry2

1

Procedure

  1. Create an Internet-facing SLB instance.

    For details, see Create a server load balancer.

  2. Resolve the domain name into the public IP of the SLB instance by using DNS.

    For convenience, the public IP of the SLB instance is bound to domain name www.aaa.com in the host file in this case.

  3. Create two VServer groups.

    1. Locate the newly created instance in the Server Load Balancer console and click the instance ID to go to the Instance Details page.

    2. In the left-side navigation pane, click Server > VServer Group.

    3. Click Create VServer Group.

    4. In the dialog box that appears, select the backend servers to be added and set ports and weights for them respectively. The ports for ECSs in the VServer group can be different.

      In this case, enter TOM as the server group name, add server SLB_tom1 and server SBL_tom2 into the group, set the port number to 80, and keep the default weight value (100).

      2

    5. Repeat the preceding steps to add another VServer group named JERRY, which includes server SLB_jerry1 and server SBL_jerry2.

  4. Add a listener.

    1. In the left-side navigation pane, click Listeners, and click Add Listener.

    2. Configure the listener. In this case, the listener is configured as follows:

      • Frontend protocol [Port]: HTTP: 80
      • Backend protocol [Port]: HTTP: 80
      • Scheduling algorithm: Round-robin.
      • Keep the default values for other configuration items.
    3. On the Listeners page, click More > Add Forwarding Rules.

      3

    4. On the Forwarding rules page, click Add Forwarding Rules.

    5. Configure three forwarding rules.

      4

  5. Test:

    • Enter www.aaa.com/jerry in the browser and the following result is returned.

      test1

    • Enter www.aaa.com/tom in the browser and the following result is returned.

      test2

    • Enter www.aaa.com in the browser and the following result is returned.

      all

Thank you! We've received your feedback.