This topic describes how to add on-premises servers in a data center to an Application Load Balancer (ALB) instance within the same region. ALB can work with transit routers of Cloud Enterprise Network (CEN) to forward requests to servers in a data center.
Example
ALB supports backend servers in data centers. This example shows how to add on-premises servers in a data center to an ALB instance within the same region.
A company created a virtual private cloud (VPC) named VPC1 in the China (Chengdu) region. An ALB instance is created in VPC1. The company wants the ALB instance in VPC1 to forward requests to on-premises servers in a data center in the China (Chengdu) region.
To meet this requirement, the company can use CEN to connect VPC1 and a virtual border router (VBR) to the transit router in the China (Chengdu) region. The data center is connected to Alibaba Cloud through the VBR. The ALB instance can forward requests to the data center by using CEN. In this solution, the on-premises servers in the data center are added to the ALB instance as backend servers.
The following table describes how networks are designed in this example. You can plan CIDR blocks based on your business requirements. Make sure that the CIDR blocks do not overlap with each other.
China (Chengdu) | vSwitch | vSwitch zone | CIDR block |
VPC1 Primary CIDR block: 172.16.0.0/12 | VSW1 | Zone A | 172.16.0.0/24 |
VSW2 | Zone B | 172.16.6.0/24 | |
VBR | N/A | N/A | IPv4 address on the customer side: 10.0.0.2/30 IPv4 address on the Alibaba Cloud side: 10.0.0.1/30 |
Data center | VSW3 | N/A | 192.168.20.0/24 |
Precautions
You can add an on-premises server to an ALB instance only by specifying the IP address of the on-premises server.
You can add on-premises servers to internal-facing ALB instances or Internet-facing ALB instances.
You can add on-premises servers to an ALB instance within the same region or across regions.
Area
Region
China
China (Chengdu), China (Qingdao), China (Beijing), China (Guangzhou), China (Hangzhou), China (Ulanqab), China (Shanghai), China (Shenzhen), China (Zhangjiakou), and China (Hong Kong)
Asia Pacific
Indonesia (Jakarta), Japan (Tokyo), Malaysia (Kuala Lumpur), and Singapore
Europe & Americas
Germany (Frankfurt), UK (London), US (Virginia), and US (Silicon Valley)
When you associate Enterprise Edition transit routers with the VPCs, elastic network interfaces (ENIs) are automatically created. Then, the ENIs are attached to the vSwitch in each zone. The ENIs are used to forward network traffic from the VPCs to the Enterprise Edition transit routers. When you create the VPCs, you must specify at least one vSwitch in each zone of the Enterprise Edition transit routers. This way, network traffic can be routed from the VPCs to the transit routers. For more information, see Regions and zones that support Enterprise Edition transit routers.
You can add only internal-facing servers. Internet-facing servers are not supported.
You cannot add a backend server of the IP type to an ALB instance, a Network Load Balancer (NLB) instance, or a Classic Load Balancer (CLB) instance in the same VPC.
Make sure that no loops exist. ALB adds the ALICLOUD-ALB-TRACE HTTP header to each request to detect loops. If a loop is detected, ALB stops forwarding requests to backend servers and returns the 463 status code in case a network storm arises and exhausts all resources.
You can use Enterprise Edition transit routers and Express Connect circuits for cross-region forwarding. Basic Edition transit routers are not supported.
For the same CEN instance, each region can have only one VPC in which one or more ALB instances use on-premises servers as backend servers.
ALB instances in different VPCs within the same region cannot use the same transit router to access on-premises servers.
ALB instances in different VPCs within the same region cannot use different transit routers to access the same on-premises server.
Network traffic between an ALB instance and its backend servers can be routed based only on the system route table. VPC custom route tables are not supported.
Prerequisites
VPC1 is created in the China (Chengdu) region. Two vSwitches named VSW1 and VSW2 are deployed in VPC1. VSW1 is deployed in Zone A. VSW2 is deployed in Zone B. For more information, see Create and manage a VPC.
An ALB instance is created in VPC1. For more information, see Create an ALB instance.
An Elastic Compute Service (ECS) instance is deployed in VPC1. Applications are hosted on the ECS instance. In this example, the ECS instance is named ECS1. For information about how to create an instance, see Create an instance by using the wizard.
A domain name is registered, an Internet content provider (ICP) number is obtained for the domain neme, and a CNAME record is created to map the domain name to the domain name of your ALB instance. For more information, see Register a generic domain name, ICP filing process, and Add a CNAME record to an ALB instance.
A CEN instance is created, and a transit router is deployed in the China (Chengdu) region. For more information, see Create a CEN instance and Create a transit router.
A connection over an Express Connect circuit is established and a VBR is created. For more information, see Create and manage a dedicated connection over an Express Connect circuit and Create and manage a VBR.
Procedure
Step 1: Create a server group for the ALB instance
Create a server group of the IP type and add the IP address of the on-premises server to the server group.
- Log on to the ALB console.
In the top navigation bar, select the region where the ALB instance resides. In this example, China (Chengdu) is selected.
In the left-side navigation pane, choose .
On the Server Groups page, click Create Server Group, configure the parameters, and then click Create.
The following table describes only the parameters that are relevant to this topic. You can use the default values for the other parameters. For more information, see Create and manage server groups.
Parameter
Description
Server Group Type
Select the type of server group that you want to create. In this example, IP is selected.
Server Group Name
Enter a name for the server group.
VPC
Select a VPC from the drop-down list. In this example, VPC1 is selected.
Backend Server Protocol
Select a backend protocol. In this example, HTTP is selected.
NoteHTTPS listeners of basic ALB instances support only HTTP server groups.
Scheduling Algorithm
Select a scheduling algorithm. In this example, the default value Weighted Round-robin is used.
In the Server group created. dialog box, click Add Backend Server .
On the Backend Servers tab, click Add IP Address.
In the Add Backend Server panel, enter the IP address of the on-premises server, turn on Remote IP, and then click Next.
If you enable the remote IP address feature, IP addresses that fall into the following CIDR blocks are supported:
10.0.0.0/8
100.64.0.0/10
172.16.0.0/12
192.168.0.0/16
If you do not enable the remote IP address feature, only IP addresses that fall into the CIDR block of the VPC in which the server group is created are supported.
Specify the port and weight of the IP address and click OK. In this example, the port is set to 80, and the default weight is used.
Step 2: Create a listener for the ALB instance
- Log on to the ALB console.
In the top navigation bar, select the region where the ALB instance resides. In this example, China (Chengdu) is selected.
On the Instances page, find the ALB instance that is created in VPC1 and click Create Listener in the Actions column.
In the Configure Listener step, configure the parameters and click Next. The following table describes some of the parameters. You can use the default values for the other parameters.
Parameter
Description
Listener Protocol
Select a listener protocol. In this example, HTTP is selected.
Listener Port
Specify the port on which the ALB instance listens. The ALB instance listens for requests on the specified port and then forwards the requests to backend servers. Valid values: 1 to 65535. In this example, 80 is specified.
Listener Name
Enter a name for the listener.
In the Server Group step, select IP from the Server Group drop-down list, select the server group that you created in Step 1, and then click Next.
In the Confirm step, confirm the configurations and click Submit.
Step 3: Attach the VPC to the CEN instance
Log on to the CEN console.
On the Instances page of the CEN console, click the ID of the CEN instance that you created.
On the tab, find the transit router that you want to manage and click Create Connection in the Actions column.
On the Connect with Peer Network Instance page, configure the parameters and click OK. The following table describes the parameters.
Parameter
Description
Instance Type
In this example, Virtual Private Cloud is selected.
Region
Select the region where the network instance is deployed. In this example, China (Chengdu) is selected.
Transit Router
The transit router deployed in the selected region is selected by default.
Resource Owner ID
Specify whether the network instance belongs to the current account or another Alibaba Cloud account. In this example, Current Account is selected.
Billing Method
In this example, Pay-As-You-Go is selected.
Attachment Name
Enter a name for the connection.
Network Instance
Select the ID of the VPC that you want to attach to the CEN instance. In this example, VPC1 is selected.
vSwitch
Select a vSwitch that is deployed in a zone supported by Enterprise Edition transit routers. In this example, VSW1 and VSW2 are selected.
Advanced Settings
By default, the advanced settings are selected. In this example, the advanced features are enabled.
Step 4: Attach the VBR to the CEN instance
After you attach VPC1 to the CEN instance, click Create More Connections.
On the Connect with Peer Network Instance page, configure the parameters and click OK. The following table describes the parameters.
Parameter
Description
Instance Type
In this example, Virtual Border Router (VBR) is selected.
Region
Select the region where the network instance is deployed. In this example, China (Chengdu) is selected.
Transit Router
The transit router deployed in the selected region is selected by default.
Resource Owner ID
Specify whether the network instance belongs to the current account or another Alibaba Cloud account. In this example, Current Account is selected.
Attachment Name
Enter a name for the connection.
Network Instance
Select the ID of the VBR that you want to attach to the CEN instance. In this example, the VBR deployed in the China (Chengdu) region is selected.
Advanced Settings
By default, the advanced settings are selected. In this example, the advanced features are enabled. For more information, see Create a VBR connection.
Step 5: Add routes to the system route table of VPC1
Check whether the system route table of VPC1 contains a route whose destination is the VPC1 connection. If no such route exists, perform the following operations to add a route.
Network traffic between an ALB instance and its backend servers can be forwarded only based on the system route table. Forwarding based on VPC custom route tables is not supported.
Log on to the VPC console.
On the VPCs page, click the ID of VPC1.
On the details page of VPC1, click the Resources tab and then click the number below Route Table.
On the Route Tables page, find the route table whose Route Table Type is System and click its ID.
On the details page of the route table, choose and click Add Route Entry.
In the Add Route Entry panel, configure the parameters and click OK. The following table describes the parameters.
Parameter
Description
Name
Enter a name for the route.
Destination CIDR Block
Enter the destination CIDR block. In this example, the CIDR block of the on-premises server is entered, which is 192.168.20.0/24.
Next Hop Type
Select a type of next hop. In this example, Transit Router is selected.
Transit Router
Select a transit router. In this example, the VPC1 connection is selected.
Step 6: Add VBR routes
Add a route that points to the data center to the route table of the VBR.
Log on to the Express Connect console.
In the top navigation bar, select a region and click Virtual Border Routers (VBRs) in the left-side navigation pane.
On the Virtual Border Routers (VBRs) page, click the ID of the VBR that you want to manage.
On the details page of the VBR, click the Routes tab and click Add Route.
In the Add Route panel, configure the parameters and click OK. The following table describes the parameters.
Parameter
Description
Next Hop Type
Select a type of next hop. In this example, Physical Connection Interface is selected.
Destination CIDR Block
In this example, the CIDR block of the on-premises server is entered, which is 192.168.20.0/24.
Next Hop
Select an Express Connect circuit.
Step 7: Add back-to-origin routes
View the back-to-origin route of the ALB instance, and add the back-to-origin route to the transit router associated with VPC1 and the data center.
Perform the following operations to view the back-to-origin route of an ALB instance:
Log on to the ALB console.
In the top navigation bar, select the region where the ALB instance resides. In this example, China (Chengdu) is selected.
On the Instances page, click the ID of the ALB instance that is created in VPC1.
Click the Instance Details tab, and then click View next to Back-to-origin Route.
Perform the following operations to add the back-to-origin route of the ALB instance to the transit router associated with VPC1:
Log on to the CEN console.
On the Instances page, click the ID of the CEN instance that you created.
On the tab, click the ID of the transfer router that is associated with VPC1.
On the Route Table tab, click the ID of the route table to which you want to add the back-to-origin route, click the Route Entry tab, and then click Add Route Entry.
In the Add Route Entry dialog box, configure the parameters and click OK. The following table describes the parameters.
Parameter
Description
Route Table
By default, the current route table is selected.
Transit Router
By default, the current transit router is selected.
Name
Enter a name for the route.
The name must be 0 to 128 characters in length, and can contain letters, digits, commas (,), periods (.), semicolons (;), forward slashes (/), at signs (@), underscores (_), and hyphens (-).
Destination CIDR Block
Enter the destination CIDR block of the route. In this example, the destination CIDR block of the back-to-origin route of the ALB instance is entered. If the ALB instance has multiple back-to-origin routes, repeat the preceding operations to add all back-to-origin routes.
Blackhole Route
By default, No is selected.
Next Hop
Select a next hop. In this example, the VPC1 connection is selected.
Description
Enter a description for the route.
The description must be 2 to 256 characters in length, and can contain letters, digits, commas (,), periods (.), semicolons (;), forward slashes (/), at signs (@), underscores (_), and hyphens (-).
Perform the following operations to add the back-to-origin route of the ALB instance to the data center:
Add the back-to-origin route of the ALB instance to the on-premises gateway device. The following code shows an example. If the ALB instance has multiple back-to-origin routes, repeat the preceding operations to add all of the back-to-origin routes.
NoteThe route configuration in this example is for reference only. The configuration may vary based on the gateway device.
ip route 100.XX.XX.0/25 255.255.255.128 The VBR IP address on the Alibaba Cloud side
Step 8: Test network connectivity
Log on to the ECS instance that is deployed in VPC1. For more information, see Methods for connecting to an ECS instance.
Run the
curl http://<Domain name>
command to test whether the ECS instance in VPC1 can access the on-premises server in the data center by using the ALB instance.In this example, the following command is used:
curl http://www.example.com
If you can receive an echo reply packet as expected, the ECS instance can access the on-premises server.