×
Community Blog How to Use Alibaba Cloud DNS's Private Zone and GTM Features

How to Use Alibaba Cloud DNS's Private Zone and GTM Features

In this article, we'll show you how to use Alibaba Cloud DNS and Global Traffic Manager to route access traffic of an application service to different regional IP addresses.

By Victor Mak, Solutions Architect

In this article, we'll show you how to use Alibaba Cloud DNS's Private Zone to quickly build a DNS in one or more specified VPCs and resolve private domain names to IP addresses. We'll also use Global Traffic Manager (GTM) to route users' access traffic of an application service to different regional IP addresses.

After successfully building your website or mobile app, you may want to use DNS instead of IP Address for private access across VPCs. For public access, you may want to route the users' access traffic to the nearest servers based on their geolocation IP addresses.

In this tutorial, we will be combining several Alibaba Cloud products, including Elastic Compute Service (ECS), Alibaba Cloud DNS and Global Traffic Manager (GTM).

The following will be a step-by-step explanation about how to configure the whole setup in under 30 minutes.

We have set up and internet accessible website, hosted on an Alibaba Cloud ECS server (Hong Kong Region): http://47.52.230.124

1

We'll add an ECS Nginx proxy in Alibaba Cloud (Shenzhen Region) to proxy Mainland China visitors and route back the traffics to original ECS server by use private domain name.

The following figure illustrates the solution architecture:

2
Setting Up Alibaba Cloud DNS Private Zone

Navigate to Private Zone under Alibaba Cloud DNS console, Click Add Zone in right side and give a zone name. In this tutorial, we will use aliyun.local as the zone name.

3

We need to add at least one DNS entry before we can bind to VPC. Click the zone name then you can add DNS entry by click Add Record in the right side. In this tutorial, we will add an "A Record" and point to website public IP address.

4

5

We are now able to bind VPC correctly. In this tutorial, bind Shenzhen VPC to this private zone. The Bind VPC status will be changed to Bind afterward.

6

7
Setting ECS reversed proxy in Shenzhen Region

We'll add one ECS in Shenzhen Region to proxy Mainland China visitor traffic. Linux ECS server with Nginx are recommended.

8

Login to the proxy server. We are able to communicate with ECS (HK region) using DNS now.

9

Modify proxy server Nginx configuration. Use Nginx upstream module to proxy all the Mainland China traffic to original server. For more details, see Nginx reverse proxy configuration.

 upstream backend {
        server original-website.aliyun.local;
    }
location / {
          proxy_pass http://backend;
        }

After restarting the Nginx service, we should see original website through ECS (Shenzhen Region) public IP address http://120.79.239.228

10
Setting Up Alibaba Cloud DNS Private Zone

Navigate to Global Traffic Manager under Alibaba Cloud DNS console, Click Authorize Now to enable GTM feature.

11

Click Confirm Authorization Policy

12

We are now ready to Create Instance in Global Traffic Manager console. GTM instance is currently in public beta and is still available free of charge.

13

14

The system will give us a CNAME address after we purchase a GTM instance. The CNAME address will be used to configure DNS CNAME record later. Click Configure in right side

15

In Global Settings, we need to first configure Instance Name, Primary Domain and Alert Group. Click Edit in right side. We use website.alibabacloudhk.com as Primary Domain.

16

Next, we need to define two Address pools in Address Pool Configurations.

  1. oversea-dns: use HK ECS public IP address

    17

  2. china-dns: use SZ ECS public IP address

    18

    Go to Access policy, select Add Access Policy in right side and configure DNS routing based on access region.

  3. oversea-policy configuration:
    1. Default Address Pool use oversea-dns we created before.
    2. Select all oversea regions in access region list.

    19

  4. china-policy configuration:
    1. Default Address Pool use china-dns we created before.
    2. Select all Mainland China regions in access region list.

    20
    Add DNS record in Alibaba Cloud DNS Service


Navigate to Domains under Alibaba Cloud DNS console. click on the domain name and click Add Record in right side.

21

Add a CNAME record and bind website.alibabacloudhk.com to GTM instance CNAME address.

22
Verifying the Results from Oversea and Mainland China

We can find any machines located in Oversea and China. Ping the hostname and DNS will return different IP addresses.

  1. Machine in Hong Kong:

    23

  2. Machine in China:

    24


Now the website is able to route users to different web servers based on the visitor's geolocation.
0 0 0
Share on

Alibaba Clouder

2,605 posts | 747 followers

You may also like

Comments

Alibaba Clouder

2,605 posts | 747 followers

Related Products

  • DNS

    Alibaba Cloud DNS is an authoritative high-availability and secure domain name resolution and management service.

    Learn More
  • VPC

    A virtual private cloud service that provides an isolated cloud network to operate resources in a secure environment.

    Learn More
  • CEN

    A global network for rapidly building a distributed business system and hybrid cloud to help users create a network with enterprise level-scalability and the communication capabilities of a cloud network

    Learn More