You can associate a Server Load Balancer (SLB) instance with the instances of multiple applications to save costs. These applications share a public IP address and port. You can configure forwarding policies to forward requests to the applications. This topic describes how to configure domain names to forward traffic for multiple applications whose instances are associated with the same SLB instance and share the same port.
Background information
SLB instances support the HTTP protocol and can forward traffic based on the domain
names and URLs in HTTP requests. In the following figure, the IP address of the SLB
instance is mapped to the following domain names that are associated with the vServer
groups of App1 and App2: abc***.com
and xyz***.com
. After the SLB instance receives HTTP requests, the SLB instance forwards traffic
based on the domain names in the HTTP requests. The SLB instance forwards traffic
to vServer Group A of App1 if the domain name is abc***.com
and to vServer Group B of App2 if the domain name is xyz***.com
.
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. By default, port 80 is used. You can configure different domain names to forward traffic for the applications. In this example, u.domain.com is configured for the User application and o.domain.com is configured for the Order application.
Procedure
The following procedure shows you how to associate an SLB instance with the instances of two different applications and configure different domain names to forward traffic:
- Create an SLB instance named edas-test-slb. For more information, see Create a CLB instance.
- Create an application that is deployed on an ECS cluster in the Enterprise Distributed
Application Service (EDAS) console. Name the application spring-cloud-provider. Associate
edas-test-slb with the instances of spring-cloud-provider. Set the listening protocol
to HTTP and the port number to 80. Name the forwarding rule
provider.test.com
. - Associate edas-test-slb with the instances of spring-cloud-consumer. The associating
process is similar to that of associating edas-test-slb with the instances of spring-cloud-provider.
The only difference is that the forwarding rule you create for spring-cloud-consumer
is named
consumer.test.com
.
After you associate edas-test-slb with the instances of spring-cloud-provider and
spring-cloud-consumer, you can add the following entries to the /etc/hosts file on your Linux or macOS client if the IP address of the SLB instance is 123.1.XX.XX
.
123.1.XX.XX provider.test.com
123.1.XX.XX consumer.test.com
Then, you can use http://provider.test.com
to access spring-cloud-provider and http://consumer.test.com
to access spring-cloud-consumer.
Associate the SLB instance with the instances of the first application and configure a domain name-based forwarding policy
Associate the SLB instance with the instances of the first application, and configure a listening port, vServer group, and domain name-based forwarding policy.
Associate the SLB instance with the instances of the second application and configure a domain name-based forwarding policy
Log on to the EDAS console. On the Applications page, click the name of the second application. In the Application Settings section of the Basic Information tab, repeat the operations described in the Associate the SLB instance with the instances of the first application and configure a domain name-based forwarding policy section of this topic. The SLB instance that you associate with and the listening port that you set for the second application are the same as those for the first application. The only differences are the vServer group and the domain name-based forwarding policy.