Use a single Global Accelerator instance to accelerate access to multiple HTTP domains.
Background
A company with headquarters in the Singapore region has two servers on Alibaba Cloud. Each server hosts a web application accessible via a different domain name. The company's clients are primarily in the China (Hong Kong) region. The web applications face the following challenges:
Unstable Internet connections frequently cause network issues such as high latency, jitter, and packet loss.
Multiple servers provide services through different domain names. To accelerate the web applications, you must configure acceleration for each domain name separately, which increases costs.
Deploy Global Accelerator and configure an HTTP listener with domain-based forwarding rules. The listener matches access domains and forwards requests to the corresponding backend servers, allowing a single Global Accelerator instance to accelerate access to multiple HTTP domains simultaneously.
The following table lists the web server details and the request forwarding plan after configuring Global Accelerator.
Domain name | Forwarding rule | Endpoint group | Server | Server protocol | Server port | Public IP address |
xxxtest.cloud | Default forwarding rule | Default endpoint group | Server 1 | HTTP | 80 | 8.219.XX.XX |
www.xxxtest.cloud | Custom forwarding rule | Virtual endpoint group | Server 2 | HTTP | 80 | 47.245.XX.XX |
Prerequisites
An HTTP service is configured on port 80 of your backend servers.
A records are added to point domain name 1 (
xxxtest.cloud) and domain name 2 (www.xxxtest.cloud) to the public IP addresses of the backend servers.If the web application that you want to accelerate is deployed in the Chinese mainland or the acceleration region is in the Chinese mainland, you must complete an ICP filing before you can provide services.
This topic uses NGINX to configure the backend HTTP service on port 80 and uses Alibaba Cloud DNS to add DNS records as an example. If you use a DNS provider other than Alibaba Cloud, refer to your DNS provider’s documentation.
This example uses a pay-as-you-go standard Global Accelerator instance to configure acceleration for multiple HTTP domains. Before you create a pay-as-you-go standard Global Accelerator instance, note the following information:
Pay-as-you-go GA instances use Pay-By-Data-Transfer for bandwidth billing. You do not need to associate a bandwidth package. Cloud Data Transfer (CDT) handles traffic billing.
The first time you use a pay-as-you-go GA instance, you must Activate the Service.
Step 1: Configure basic information
Log on to the Global Accelerator console.
On the Instances page, click Create Standard Pay-as-you-go Instance.
On the Basic Instance Configuration wizard page, configure the following parameters and click Next.
Parameter
Description
GA Instance Name
Enter a name for the Global Accelerator instance.
Instance Billing Method
The default value is Pay-As-You-Go.
A pay-as-you-go standard Global Accelerator instance incurs instance fees, capacity unit (CU) fees, and data transfer fees.
Resource Group
Select the resource group to which the standard Global Accelerator instance belongs.
The resource group must be created in Resource Management under your Alibaba Cloud account.
Step 2: Configure an acceleration area
Configure an acceleration area for the Global Accelerator instance to specify the regions where users who need accelerated access to the backend service are located, and allocate bandwidth to these regions.
On the Configure acceleration areas wizard page, configure the acceleration area based on the following information and click Next.
Parameter | Description |
Acceleration Area | Select one or more regions that require acceleration from the drop-down list, and then click Add to List. In this example, select China (Hong Kong) in the Asia Pacific area. |
Assign Bandwidth | |
Maximum Bandwidth | Set the bandwidth for the acceleration region. You can allocate 2 to 10,000 Mbps to each acceleration region. The maximum bandwidth is used only for rate limiting. Data transfer fees are billed by CDT. In this example, keep the default value of 200 Mbps. Important If the maximum bandwidth is too low, rate limiting may cause traffic to be dropped. Set the maximum bandwidth based on your business requirements. |
IP Protocol | Select the IP address protocol used to access Global Accelerator. In this example, keep the default value of IPv4. |
ISP Line Type | Select the ISP line type used to access Global Accelerator. In this example, select BGP (Multi-ISP). |
Step 3: Configure a listener
A listener checks for and processes inbound connection requests based on the port and protocol you specify. Associate an endpoint group with the listener to specify the region to which traffic is forwarded. Global Accelerator then routes traffic to the optimal endpoint in the associated endpoint group.
On the Configure Listeners wizard page, configure the listener and click Next.
The following table describes only the parameters relevant to this example. Keep the default values for other parameters. For more information, see Add and manage intelligent routing listeners.
Parameter | Description |
Listener Name | Enter a name for the listener. |
Routing Type | Select a routing type. In this example, select Intelligent Routing. |
Protocol | Select a protocol for the listener. In this example, select HTTP. |
Port | Specify the listener port that is used to receive and forward requests to endpoints. The port number must be in the range of 1 to 65499. In this example, enter 80. |
Client Affinity | Specify whether to enable client affinity. Client affinity forwards requests from the same client to the same endpoint when the client accesses a stateful application. In this example, select Source IP Address. |
Custom HTTP Headers | Select the HTTP headers that you want to add. In this example, keep the default settings. |
Step 4: Configure an endpoint group and endpoints
In the Configure an Endpoint Group step, configure an endpoint group and its endpoints. Then, click Next.
Only parameters relevant to this scenario are described here. For more information, see Add and manage endpoint groups for an Intelligent Routing listener.
Parameter
Description
Region
Select the region where the endpoint group is deployed.
In this example, Singapore is selected.
Endpoint Configuration
An endpoint is the destination to which client requests are forwarded. Set the following parameters to configure an endpoint:
Backend Service Type: Select Alibaba Cloud Public IP Address.
Backend Service: Enter the IP address of the backend service that you want to accelerate. In this example, enter the public IP address of Server 1, which is 8.219.XX.XX.
Weight: Enter a weight from 0 to 255 for the endpoint. Global Accelerator distributes traffic to endpoints based on their specified weights. In this example, the default value 255 is used.
WarningIf the weight of an endpoint is set to 0, Global Accelerator stops distributing traffic to that endpoint. Proceed with caution.
Preserve Client IP
By default, Preserve client IP is enabled, which allows backend servers to retrieve client source IP addresses from the x-forwarded-for HTTP header. For more information, see Preserve client IP addresses.
Backend Service Protocol
Select the protocol that is used by the backend servers.
The default value is HTTP.
Port Mapping
If the listener port is different from the service port of your endpoint, you must specify a port mapping.
Listener Port: You can only enter the port of the current listener.
Endpoint Port: The service port of your endpoint.
If the listener port is the same as the service port of your endpoint, you do not need to configure a port mapping. Global Accelerator automatically forwards requests to the listener port of the endpoint.
In this example, no port mapping is configured.
Traffic Distribution Ratio
Specify the traffic distribution ratio to different endpoint groups.
In this example, the default value 100% is used.
Valid values: 0 to 100.
Health Check
Enables or disables health checks.
In this example, this feature is disabled by default.
After health checks are enabled, you can check the health status of endpoints. For more information about health checks, see Health checks.
On the Configuration Review page, review the settings and click Submit. Creating a GA instance takes about 3 to 5 minutes.
Optional: After the instance is created, click Go to Instance Details at the bottom of the task list. On the instance details page, you can click the Instance Information, Listeners, and Acceleration Areas tabs to view the instance configuration.
Configure a virtual endpoint group.
On the instance details page, click the Listeners tab.
On the Listener tab, find the listener that you want to manage and click the ID of the endpoint group in the Default Endpoint Group column.
On the Endpoint Group tab, in the Virtual Endpoint Group section, click Add Virtual Endpoint Group.
On the Add Endpoint Group page, set the parameters and click Create.
The parameters are similar to those for the default endpoint group. Set Backend Service to the IP address of the backend service that you want to accelerate. In this example, enter the public IP address of Server 2, which is 47.245.XX.XX.
Step 5: Add a forwarding rule
When an HTTP listener receives a request, it first tries to match it against a custom forwarding rule. If a match is found, the request is forwarded to the corresponding endpoint group. Otherwise, it is forwarded to the default endpoint group.
In this step, you create a custom forwarding rule for the virtual endpoint group of Server 2. The rule forwards all requests for the domain name www.xxxtest.cloud to Server 2.
On the listener details page, click the Forwarding Rule tab.
On the Forwarding Rule tab, click Add Forwarding Rule.
In the Add Forwarding Rule section, set the following parameters for the forwarding rule and click OK.
Name: Enter a name for the forwarding rule.
If (Matching All Conditions): Select a matching method for the forwarding condition. In this example, select Domain Name and set the domain name to match to www.xxxtest.cloud.
THEN: Select an action. In this example, select Forward to and then choose the virtual endpoint group that you created.
After the forwarding rule is configured, you can view the created forwarding rule on the Forwarding Rules tab. The status is Normal. The Listener Default Policy with the lowest priority is also displayed at the bottom, forwarding traffic to the default endpoint group associated with the listener.
Step 6: Configure CNAME records
You need to map your domain name to the CNAME address provided by Global Accelerator so that access requests can be forwarded to Global Accelerator for acceleration.
On the Domains page, find your domain name and click Configure in the Actions column.
If your domain name is not registered with Alibaba Cloud, you must first add the domain name to the Alibaba Cloud DNS console before you can configure its DNS settings.
On the Configure page, find the existing A record and click Modify in the Actions column.
The Hostname for domain name 1 is @ and the Hostname for domain name 2 is www.
In the Modify DNS Record panel, set Record Type to CNAME, change Record Value to the CNAME that is assigned to the Global Accelerator instance, and then click OK.
You can view the CNAME that is assigned to the Global Accelerator instance on the Instances page.
To return DNS results based on client regions, upgrade Alibaba Cloud DNS to Enterprise Standard Edition or Enterprise Ultimate Edition.
After the upgrade, you can change the default DNS record line of the existing A record to a specific regional DNS record line, and add a CNAME record that points to the CNAME that is assigned to the Global Accelerator instance.
Step 7: Test the configuration
Verify that clients can access the web applications through different domain names and that acceleration is working.
The following test commands apply to Alibaba Cloud Linux 3. Commands may differ on other operating systems. Refer to your OS user guide for details.
Check whether the CNAME record has taken effect.
Open the command-line interface (CLI) on a computer in the acceleration region. In this example, the acceleration region is China (Hong Kong).
Run the following command for both
xxxtest.cloudandwww.xxxtest.cloud.ping <your_domain_name>If the CNAME in the output matches the CNAME assigned by Global Accelerator, the CNAME record has taken effect.
[root@xxx ~]# ping xxx.test.cloud PING ga-bp1xxx.com (47.243.xxx.xxx) 56(84) bytes of data. 64 bytes from 47.243.xxx (47.243.xxx.xxx): icmp_seq=1 ttl=96 time=2.76 ms 64 bytes from 47.243.xxx (47.243.xxx.xxx): icmp_seq=2 ttl=96 time=2.71 ms 64 bytes from 47.243.xxx (47.243.xxx.xxx): icmp_seq=3 ttl=96 time=2.71 ms ^C --- ga-bp xxx m ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2002ms rtt min/avg/max/mdev = 2.707/2.724/2.760/0.065 ms [root@xxx ~]# ping www.xxx.test.cloud PING ga-bp1xxx.m (8.210.xxx.xxx) 56(84) bytes of data. 64 bytes from 8.210.xxx (8.210.xxx.xxx): icmp_seq=1 ttl=96 time=2.70 ms 64 bytes from 8.210.xxx (8.210.xxx.xxx): icmp_seq=2 ttl=96 time=2.71 ms 64 bytes from 8.210.xxx (8.210.xxx.xxx): icmp_seq=3 ttl=96 time=2.69 ms ^C --- ga-bp1xxx.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2003ms rtt min/avg/max/mdev = 2.689/2.697/2.707/0.043 ms
Run
curl http://<your_domain_name>for domain name 1 (xxxtest.cloud) and domain name 2 (www.xxxtest.cloud) to test website connectivity.To test the acceleration performance, see Test the acceleration performance of a GA instance.