Routing Traffic to Backend Servers in Different VPCs from the Load Balancer
You can use ELB to route traffic to backend servers in two VPCs connected over a VPC peering connection.
Solution Design​
- A dedicated load balancer named
ELB-Test
is running inVPC-Test-01
(172.18.0.0/24
). - An ECS named
ECS-Test
is running inVPC-Test-02
(172.17.0.0/24
). IP as a Backend
is enabled for the dedicated load balancerELB-Test
, andECS-Test
inVPC-Test-02
(172.17.0.0/24
) is added to the backend server group associated withELB-Test
.
You can enable IP as a Backend
for the dedicated load balancer to
route incoming traffic to servers in different VPCs from the load
balancer.
Prerequisites​
Resource Type | Resource Name | Description | Quantity |
---|---|---|---|
VPC | VPC-Test-01 | The VPC where ELB-Test is running: 172.18.0.0/24 | 1 |
VPC-Test-02 | The VPC where ECS-Test is running: 172.17.0.0/24 | 1 | |
VPC peering connection | Peering-Test | The connection that connects the VPC where ELB-Test is running and the VPC where ECS-Test is running Local VPC: 172.18.0.0/24 Peer VPC: 172.17.0.0/24 | 1 |
Route table | Route-VPC-Test-01 | The route table of VPC-Test-01 Destination: 172.17.0.0/24 | 1 |
Route-VPC-Test-02 | The route table of VPC-Test-02 Destination: 172.18.0.0/24 | 1 | |
ELB | ELB-Test | The dedicated load balancer | 1 |
EIP | EIP-Test | The EIP bound to ELB-Test | 1 |
ECS | ECS-Test | The ECS works in VPC-Test-02 | 1 |
Table 1 Resource planning
To calculate the fees you can visit Open Telekom Cloud Price calculator.
Procedure​
Creating VPCs​
-
Log in to the management console.
-
Under Networking, select Virtual Private Cloud. On the Virtual Private Cloud page displayed, 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-Test-01
- IPv4 CIDR Block:
172.18.0.0/24
- Configure other parameters as required.
- Name:
-
Repeat steps 2 & 3 to create the other VPC.
- Name:
VPC-Test-02
- IPv4 CIDR Block:
172.17.0.0/24
- Configure other parameters as required.
- Name:
Creating a VPC Peering Connection​
-
In the navigation pane on the left, click VPC Peering.
-
In the upper right corner, click Create VPC Peering Connection.
-
Configure the parameters as follows and click OK. For details on how to create a VPC peering connection, see the Virtual Private Cloud User Guide.
- Name:
Peering-Test
- Local VPC:
VPC-Test-01
- Peer VPC:
VPC-Test-02
- Configure other parameters as required.
- Name:
Adding Routes for the VPC Peering Connection​
-
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-Test-01
- Destination:
172.17.0.0/24
- Next Hop Type:
VPC peering connection
- Next Hop:
Peering-Test
- Name:
-
Repeat steps 2 & 3 to create the other route table.
- Name:
Route-VPC-Test-02
- VPC:
VPC-Test-02
- Destination:
172.18.0.0/24
- Next Hop Type:
VPC peering connection
- Next Hop:
Peering-Test
- Name:
Creating an ECS​
-
Under Computing, click Elastic Cloud Server.
-
In the upper right corner, click Create ECS.
-
Select
VPC-Test-02
as the VPC and set ECS Name toECS-Test
. Configure other parameters as required. For details, see Elastic Cloud Server User Guide. -
Deploy Nginx on the ECS.
Creating a Dedicated Load Balancer and Adding an HTTP Listener and a Backend Server Group to the Load Balancer​
-
Under Networking, click Elastic Load Balance.
-
In the upper right corner, click Create Elastic Load Balancer.
-
Configure the parameters as follows. For details, see Elastic Load Balance User Guide.
- Type:
Dedicated
- IP as a Backend:
Enable
- VPC:
VPC-Test-01
- Name:
ELB-Test
- Configure other parameters as required.
- Type:
-
Add an HTTP listener and a backend server group to the dedicated load balancer. For details, see Elastic Load Balance User Guide.
Adding the ECS to the Backend Server Group​
-
Locate the created dedicated load balancer and click its name ELB-Test.
-
On the Listeners tab page, locate the HTTP listener added to the dedicated load balancer and click its name.
-
In the Backend Server Groups tab on the right, click IP as Backend Servers.
-
Click Add IP as Backend Server, configure the parameters, and click OK. For details, see Elastic Load Balance User Guide.
- Backend Server IP Address: Private IP address of
ECS-Test
(172.17.0.205
) - Backend Port: the port enabled for Nginx on
ECS-Test
- Weight: Set this parameter as required.
- Backend Server IP Address: Private IP address of
Verifying Traffic Routing​
EIP is not necessary as long as you don't want to access the ELB externally, you can always access the ELB from its private IP.
-
Locate the dedicated load balancer ELB-Test and click More in the Operation column.
-
Select Bind IPv4 EIP to bind an EIP to
ELB-Test
. -
Enter
http://<EIP>
in the address box of your browser to access the dedicated load balancer. If the following page is displayed, the load balancer routes the request toECS-Test
, which processes the request and returns the requested page.noteIn case of unhealthy connection of the backend server group, check if the ECS subnet and ELB subnet are associated with the above created route tables.