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 request||Forward traffic to|
|www.aaa.com/tom||Server SLB_tom1 and server SBL_tom2|
|www.aaa.com/jerry||Server SLB_jerry1 and server SBL_jerry2|
Create an Internet-facing SLB instance.
For details, see Create a server load balancer.
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.
Create two VServer groups.
Locate the newly created instance in the Server Load Balancer console and click the instance ID to go to the Instance Details page.
In the left-side navigation pane, click Server > VServer Group.
Click Create VServer Group.
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).
Repeat the preceding steps to add another VServer group named JERRY, which includes server SLB_jerry1 and server SBL_jerry2.
Add a listener.
In the left-side navigation pane, click Listeners, and click Add Listener.
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.
On the Listeners page, click More > Add Forwarding Rules.
On the Forwarding rules page, click Add Forwarding Rules.
Configure three forwarding rules.
Enter www.aaa.com/jerry in the browser and the following result is returned.
Enter www.aaa.com/tom in the browser and the following result is returned.
Enter www.aaa.com in the browser and the following result is returned.