You can bind a Server Load Balancer (SLB) instance to multiple applications to save costs. These applications share a public IP address and domain name. You can configure forwarding policies to forward requests to the applications. This topic describes how to configure a domain name for multiple applications to distribute traffic.

Prerequisites

An SLB instance is created. For more information, see Create an SLB instance.

Background information

Note You can configure only HTTP listeners in ECS clusters to distribute traffic.

For example, you have two applications. One is the User application that is used to query orders. The other is the Order application that is used for user logon. Both applications use the same public IP address and port. You can configure different listening ports for the applications to distribute traffic.

通过监听端口实现流量分发

Bind an SLB instance to an application and configure a listening port

You need to bind an SLB instance to an application and configure a listening port for the application.

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, click Applications.
  3. On the Applications page, select a region in the top navigation bar and select a namespace from the Namespace drop-down list. From the Cluster Type drop-down list, select ECS Cluster. Then, click the name of the required application in the application list.
  4. In the Application Settings section of the Basic Information page, click Add next to SLB (Internet).
    Note If you have configured an SLB instance, the IP address and port number of the SLB instance are displayed. You can click Modify to go to the configuration page and modify the settings of the SLB instance. You can also click Unbind to unbind the SLB instance.
  5. Configure the SLB instance in the Bind SLB Instance to Application wizard.
    1. In the Select SLB step, select the created SLB instance from the SLB (Internet) drop-down list, and then click Next.
      选择SLB实例

      If the specified SLB instance has been bound to another application, the following message appears on the page:

    2. In the Select and Configure Listener step, configure a listening port, and then click Next.
      • If you want to use the existing listening port that is configured for the specified SLB instance, select Select an Existing Listening Port and then select the listening port.
        Note If you bind an SLB instance to multiple applications, you must select a listening port when you configure a listening port to distribute traffic. Make sure that the listening port is not bound to another application.
      • If no listening port has been configured for the specified SLB instance or you want to add a listening port to the application, select Add Listening Port and then create a listener.

        Parameters

        Parameter Description
        Protocol TCP and HTTP are supported. Select a protocol as needed. For more information, see Listener overview.
        Frontend Port Number The number of the port that is used by the SLB instance to provide external services.
        Notice If the listening port number that you want to add is already occupied by another listening protocol, you need to set another port number. You can also log on to the SLB console to delete the occupied listening port, and then add the port in the EDAS console.
        Health Check Path (URI) The URI that is used by the SLB instance to check the status of the backend application. Enter a valid URI. For more information, see Configure health check.
        Backend Port Number The port number of the application. The value cannot be modified.
    3. In the Configure Virtual Groups and Forwarding Policies step, configure a vServer group for the SLB instance, and then click Next.
      Note If you bind an SLB instance to multiple applications and distribute traffic by using different listening ports, you do not need to configure forwarding policies.
      • If no vServer group is available, all requests are forwarded to ECS instances that reside in the default server group.
        Note The default server group does not support forwarding policies.
      • If you need to configure forwarding policies, you must use vServer groups. You can use the following methods to configure vServer groups for applications:
        • If you want to use a vServer group created for the specified SLB instance, select Existing VServer Group and select an existing vServer group.
          Notice Each vServer group can be bound to only an application or instance group.
        • If no vServer group is configured for the specified SLB instance or you want to configure a new vServer group, select Create VServer Group and specify VServer Group Name.
    4. In the Confirm SLB Change step, check the settings of the SLB instance. Then, click Confirm.
  6. Check whether the IP address and port number of the bound SLB instance can access the current application. For more information, see Verify the result.

Bind an SLB instance to the other application and configure a listening port

You need to bind the same SLB instance to the other application and configure a different listening port for the application.

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. In the upper part of the page, select a namespace. On the Applications page, click the name of the desired application.
  3. In the Application Settings section of the Basic Information page, click Add next to SLB (Internet).
    Note If you have configured an SLB instance, the IP address and port number of the SLB instance are displayed. You can click Modify to go to the configuration page and modify the settings of the SLB instance. You can also click Unbind to unbind the SLB instance.
  4. Configure the SLB instance in the Bind SLB Instance to Application wizard.
    1. In the Select SLB step, select the created SLB instance from the SLB (Internet) drop-down list, and then click Next.
    2. On the Configure Listener tab, select Add New Listener Port, create a listener for the SLB instance, and then click Next.

      Parameters

      Parameter Description
      Protocol TCP and HTTP are supported. Select a protocol as needed. For more information, see Listener overview.
      Frontend Port Number The number of the port that is used by the SLB instance to provide external services.
      Notice If the listening port number that you want to add is already occupied by another listening protocol, you need to set another port number. You can also log on to the SLB console to delete the listening port, and then add the port in the EDAS console.
      Health Check Path (URI) The URI that is used by the SLB instance to check the status of the backend application. The default value is /_ehc.html. Enter a valid URI. For more information, see Configure health check.
      Backend Port Number The port number of the application. The value cannot be modified.
    3. In the Configure Virtual Groups and Forwarding Policies step, configure a vServer group for the SLB instance, and then click Next.
      Note If you bind an SLB instance to multiple applications and distribute traffic by using different listening ports, you do not need to configure forwarding policies.

      The default server group or vServer group of an SLB instance can be bound to only one application or instance group. Make sure that the server groups bound to the applications are different. Otherwise, an error may occur when the SLB instance is bound to the applications. Therefore, we recommend that you select Create VServer Group and specify VServer Group Name to create a vServer group for the current application.

    4. In the Confirm SLB Change step, view the specified SLB instance information. Then, click Confirm.
  5. Check whether the IP address and port number of the bound SLB instance can access the current application. For more information, see Verify the result.