AWS的Route53是可以注册域名的,但是如果在外部注册的域名怎么在Route53里使用呢,这里使用外网的DNS服务的Godaddy注册域名,并在AWS的Route53里使用。
注册域名并下载Zonefile
在Godaddy里注册域名xionghuilin.club,并在管理域名里下载Zonefile, 自动下载并命名为xionghuilin.club.txt
在Route53里创建hosted zone
在Route53里创建hosted zone
,会自动生成SOA和NS,如下:
在Godaddy中添加新生成的NS
以下四条NS需要添加到Godaddy中,xionghuilin.club的name server如下:
这里在Godaddy里添加name server的时候要去掉最后的点,不然输入会不成功。
结果如下:
创建两个EC2实例
使用以下启动脚本在新加坡创建一个EC2的实例,public IP是18.141.25.16
使用以下启动脚本在South America (São Paulo)创建另一个EC2的实例,public IP是52.67.73.251
检查两个EC2的httpd服务器都正常工作,如下:
在Route53里导入Zone file
有一个Import Zone File
按钮,导入后再添加一个Record set
,Routing Policy
以下可以选择,
Simple
Weighted
Latency
Failover
Geolocation
Multivalue Answer
在这里选择Geolocation比较好看效果,把两个公网IP地址输入到
18.141.25.16
52.67.73.251
注:以下设置地理位置的时候貌似要设置到国家。
测试
以下测试结果是根据地理位置,从新加坡访问xionghuilin.club就一直会访问新加坡的服务器。
术语
以下是一些术语的解释:
SOA, Start of Authority record
NS, Name Server Records
A Record --> Address Record
CName is Canonical Name Canonica: 意思是权威,公认的, CName can be used to resolve one domain name to another.
Alias Record:
Alias records are used to map resource record sets in your hosted zone to Elastic Load Balancers, CloudFront Distributions, or S3 buckets that are configured as websites.
Key difference: A CName cannot be used for naked domain names (Zone Apex record., you can’t have a CName for http://acloud.guru
, it must be either A record or an Alias
最后,这里并没有使用ELB, Elastic Load Balancer, 还可以在Route53里创建Health checks,也并没有测试。
Reference
Migrating a Domain to Amazon Route53