Routing Traffic to Backend Servers in the Same VPC as the Load Balancer
Scenarios
You can use ELB to route traffic to backend servers in the same VPC as the load balancer.
Solution
- Dedicated load balancer ELB-Test is running in a VPC named vpc-peering (10.1.0.0/16).
- An ECS named ECS-Test is also running in vpc-peering (10.1.0.0/16).
- IP as a Backend is enabled for ELB-Test, and ECS-Test in vpc-peering (10.1.0.0/16) is added to the backend server group associated with ELB-Test in vpc-peering.
Advantages
You can enable IP as a Backend for a dedicated load balancer to route traffic to backend servers in the same VPC as the load balancer.
Resource and Cost Planning
The actual cost shown on the Huawei Cloud console is used.
Resource Type |
Resource Name |
Description |
Quantity |
---|---|---|---|
VPC |
vpc-peering |
The VPC where ELB-Test and ECS-Test are running: 10.1.0.0/16 |
1 |
VPC peering connection |
Peering-Test |
The connection that connects the VPC where ELB-Test is running and other VPCs. Local VPC: 10.1.0.0/16 Peer VPC: any VPC |
1 |
Route table |
Route-VPC-Test-01 |
The route table of VPC-Test-01. Destination: 10.1.0.0/16 |
1 |
ELB |
ELB-Test |
The dedicated load balancer to distribute incoming traffic. Private IP address: 10.1.0.9 |
1 |
EIP |
EIP-Test |
The EIP bound to ELB-Test: 120.46.131.153 |
1 |
ECS |
ECS-Test |
The ECS that is running in vpc-peering. Private IP address: 10.1.0.56 |
1 |
Operation Process
Step 1: Create a VPC
- Log in to the management console.
- Choose Networking > Virtual Private Cloud. On the displayed page, click Create VPC.
- Configure the parameters as follows and click Create Now. For details on how to create a VPC, see the Virtual Private Cloud User Guide.
- Name: vpc-peering
- IPv4 CIDR Block: 10.1.0.0/16
- Configure other parameters as required.
Step 2: Create a VPC Peering Connection
- In the navigation pane on the left, click VPC Peering Connections.
- In the upper right corner, click Create VPC Peering Connection.
- Configure the parameters as follows and click Create Now. For details on how to create a VPC peering connection, see the Virtual Private Cloud User Guide.
- Name: Peering-Test
- Local VPC: vpc-peering
- Peer VPC: any VPC
- Configure other parameters as required.
Step 3: Add Routes for Peering-Test
- In the navigation pane on the left, click Route Tables.
- In the upper right corner, click Create Route Table.
- Configure the parameters as follows and click OK. For details on how to create a route table, see the Virtual Private Cloud User Guide.
- Name: Route-VPC-Test-01
- VPC: vpc-peering
- Destination: 10.1.0.0/16
- Next Hop Type: VPC peering connection
- Next Hop: Peering-Test
Step 4: Create an ECS
- Under Compute, click Elastic Cloud Server.
- In the upper right corner, click Buy ECS.
- Configure the parameters as required. For details, see the Elastic Cloud Server User Guide.
Select vpc-peering as the VPC and set Name to ECS-Test.
- Deploy Nginx on the ECS-Test.
Figure 3 Deploying Nginx on ECS-Test
Step 5: Create a Dedicated Load Balancer with an HTTP Listener and Associate a Backend Server Group
- On the management console, choose Networking > Elastic Load Balance.
- In the upper right corner, click Buy Elastic Load Balancer.
- Configure the parameters as follows. For details, see Elastic Load Balance User Guide.
- Type: Dedicated
- VPC: vpc-peering
- Name: ELB-Test
- IP as a Backend: Enable it.
- Configure other parameters as required.
- Add an HTTP listener to ELB-Test and associate a backend server group with it.
Step 6: Add ECS-Test to the Backend Server Group
Locate ELB-Test and click its name.
- On the Default Backend Server Group area of the Summary tab, click View/Add Backend Server on the right.
- The page for adding backend servers is displayed.
- Click IP as Backend Servers on the lower part of the page. Click Add on the right, set parameters as required, and click OK. For details, see Elastic Load Balance User Guide.
- IP Address: Set it to the private IP address of ECS-Test (10.1.0.56).
- Backend Port: Set it as required.
- Weight: Set it as required.
Step 7: Verify Traffic Routing
- Locate ELB-Test and click More in the Operation column.
- Select Bind IPv4 EIP to bind an EIP (120.46.131.153) to ELB-Test.
- Enter http://120.46.131.153/ in the address box of your browser to access ELB-Test. If the following page is displayed, ELB-Test routes the request to ECS-Test, which processes the request and returns the requested page.
Figure 4 Verifying that the request is routed to ECS-Test
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