All Products
Search
Document Center

Server Load Balancer:Add on-premises servers to an ALB instance within the same region

Last Updated:Feb 22, 2024

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

This topic describes how to add on-premises servers to an ALB instance within the same region. You can add on-premises servers in a data center to an ALB instance within the same region or across regions. 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 through CEN. In this solution, the on-premises servers in the data center are added as backend servers of the ALB instance.

image

The following table describes how networks are designed in this example. You can plan the 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 user 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), Australia (Sydney), Singapore, and India (Mumbai)

    Europe and 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 and cannot add Internet-facing servers.

  • 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. When 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.

    image
    • ALB instances in different VPCs within the same region cannot use the same transit router to access on-premises servers.

      image
    • ALB instances in different VPCs within the same region cannot use different transit routers to access the same on-premises server.

      image
  • Network traffic between an ALB instance and its backend servers can be routed only based on the system route table. VPC custom route tables are not supported.

Preparations

Procedure

image

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.

  1. Log on to the ALB console.
  2. In the top navigation bar, select the region where the ALB instance resides. In this example, China (Chengdu) is selected.

  3. In the left-side navigation pane, choose ALB > Server Groups.

  4. On the Server Groups page, click Create Server Group, set the following 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. HTTP is selected in this example.

    Note

    HTTPS 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.

  5. In the Server group created. dialog box, click Add Backend Server .

  6. On the Backend Servers tab, click Add IP Address.

  7. In the Add Backend Server panel, enter the IP address of the on-premises server, turn on Remote IP, and then click Next.

    • 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

    • Only IP addresses that fall into the CIDR block of the VPC in which the server group is created are supported.

  8. 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

  1. Log on to the ALB console.
  2. In the top navigation bar, select the region where the ALB instance resides. In this example, China (Chengdu) is selected.

  3. On the Instances page, find the ALB instance that is created in VPC1 and click Create Listener in the Actions column.

  4. In the Configure Listener step, set 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

    Enter 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, port 80 is selected.

    Listener Name

    Enter a name for the listener.

  5. 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.

  6. In the Confirm step, confirm the configurations and click Submit.

Step 3: Attach the VPC to the CEN instance

  1. Log on to the CEN console.

  2. On the Instances page of the CEN console, click the ID of the CEN instance that you created.

  3. On the Basic Information > Transfer Router tab, find the transit router that you want to manage and click Create Connection in the Actions column.

  4. On the Connect with Peer Network Instance page, set the following parameters and click OK.

    Parameter

    Description

    Instance Type

    In this example, Virtual Private Cloud is selected.

    Region

    Select the region where the network instance is created. 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 connect. 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

    The advanced features are selected by default. In this example, the default advanced settings are used.

Step 4: Attach the VBR to the CEN instance

  1. After you attach VPC1 to the CEN instance, click Create More Connections.

  2. On the Connect with Peer Network Instance page, set the following parameters and click OK.

    Parameter

    Description

    Instance Type

    In this example, Virtual Border Router (VBR) is selected.

    Region

    Select the region where the network instance is created. 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

    The advanced features are selected by default. In this example, the default advanced settings are used.

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.

Note

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.

  1. Log on to the VPC console.

  2. On the VPCs page, click the ID of VPC1.

  3. On the details page of VPC1, click the Resources tab and then click the number below Route Table.

  4. On the Route Tables page, find the route table whose Route Table Type is System and click its ID.

  5. On the details page of the route table, choose Route Entry List > Custom Route and click Add Route Entry.

  6. In the Add Route Entry panel, set the following parameters and click OK.

    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 the type of the next hop. Transit Router is selected in this example.

    Transit Router

    Select a transit router. In this example, the transit router that is associated with VPC1 is selected.

Step 6: Add VBR routes

Add a route that points to the data center to the route table of the VBR.

  1. Log on to the Express Connect console.

  2. In the top navigation bar, select a region and click Virtual Border Routers (VBRs) in the left-side navigation pane.

  3. On the Virtual Border Routers (VBRs) page, click the OD of the VBR that you want to manage.

  4. On the details page of the VBR, click the Routes tab and click Add Route.

  5. In the Add Route Entry panel, configure the following parameters and click OK.

    Parameter

    Description

    Next Hop Type

    Select the 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 back-to-origin routes to the transit router associated with VPC1 and the data center.

  1. Perform the following operations to view the back-to-origin route of an ALB instance:

    1. Log on to the ALB console.

    2. In the top navigation bar, select the region where the ALB instance resides. In this example, China (Chengdu) is selected.

    3. On the Instances page, click the ID of the ALB instance that is created in VPC1.

    4. Click the Instance Details tab, and then click View next to Back-to-origin Route.

  2. Perform the following operations to add the back-to-origin route of ALB to the transit router associated with VPC1:

    1. Log on to the CEN console.

    2. On the Instances page, click the ID of the CEN instance that you created.

    3. On the Basic Settings > Transfer Router tab, find the transfer router that is associated with VPC1 and click its ID.

    4. 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.

    5. In the Add Route Entry dialog box, configure the following parameters and click OK.

      Parameter

      Description

      Route Table

      The current route table is selected by default.

      Transit Router

      The current transit router is selected by default.

      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.

      In this example, the following routes are added to the transit router associated with VPC1:

      • 100.XX.XX.0/25

      • 100.XX.XX.128/25

      • 100.XX.XX.64/26

      • 100.XX.XX.128/26

      • 100.XX.XX.192/26

      • 100.XX.XX.0/26

      Blackhole Route

      The default value No is selected.

      Next Hop

      Select a next hop. In this example, the transit router that is associated with VPC1 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 (-).

  3. 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 back-to-origin routes.

    Note

    The 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

  1. Log on to the ECS instance that is deployed in VPC1. For more information, see Connect to an ECS instance.

  2. Run the wget http://Domain name command to test whether the ECS instance in VPC1 can access the on-premises server in the data center through the ALB instance.

    The following command is used in this example:

    wget http://alb-fo89znps6q********.internal.cn-chengdu.alb.aliyuncs.com

    If you can receive an echo reply packet, such as XX.html, the ECS instance can access the on-premises server.