Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am configuring a few domain names in Route53 and am looking for some advice on best practices for setting things up. Here is the scenario:

Let's say domain1.com is my master corporate domain, and I also have domain2.com and domain3.com.

Suppose I have two Amazon EC2 instances defined as a web and database server, with elastic IPs of 11.11.11.11 and 22.22.22.22 respectively, and I want to address them externally as:

 prod-web01.domain1.com
 prod-db01.domain1.com

Let's further suppose that the website for domain1.com is hosted on one of the above instances, which means that I must set an A record for domain1.com (right?) to the elastic IP of the web instance. So I create record sets in Route53 like:

 domain1.com.                A         11.11.11.11
 prod-web01.domain1.com.     A         11.11.11.11
 prod-db02.domain1.com.      A         22.22.22.22
 www.domain1.com.            CNAME     prod-web01.domain1.com

Now, both domain2.com and domain3.com are also hosted on that web01 instance above, so I create record sets for them like:

 domain2.com.                A         11.11.11.11
 www.domain2.com.            CNAME     prod-web01.domain1.com.

and

 domain3.com.                A         11.11.11.11
 www.domain3.com.            CNAME     prod-web01.domain1.com.

This all works just fine, but it is not as elegant as I was hoping for. I am wondering if there is some way to set up this type of configuration in which there are fewer records pointing to direct IP addresses.

My understanding is that I can't use a CNAME record for the root of a domain (right?), so is there some other way to set things so that I only have one "hard" reference to each IP in my DNS infrastructure?

If not, does this seem like a smart setup? Or a dumb one? Feel free to tell me I'm dumb. :)

share|improve this question

1 Answer 1

up vote 1 down vote accepted

First things first, if you only have two instances (one web and one DB), you're doing it wrong. You should be setting up an elastic load balancer with a minimum of two application server instances behind it. Instances can (and do) fail from time-to-time. And you really should be using RDS for your persistent data store.

My understanding is that I can't use a CNAME record for the root of a domain (right?)

You can, but it will frequently break stuff (esp email) in unexpected ways and shouldn't be done. This how I would do things:

 domain1.com.                A         11.11.11.11
 prod-web01.domain1.com.     A         11.11.11.11
 prod-db02.domain1.com.      A         22.22.22.22
 www.domain1.com.            CNAME     prod-web01.domain1.com

 domain2.com.                A         11.11.11.11
 www.domain2.com.            CNAME     domain2.com.

 domain3.com.                A         11.11.11.11
 www.domain3.com.            CNAME     domain3.com.
share|improve this answer
    
Right, the web/db example was just for simplicity's sake, it isn't a real configuration. So it sounds like I am not too far off then on the DNS at least. –  futureal Jul 26 '12 at 3:25
    
In your example you are pointing to IP's, yet you suggest using ELB's which do not provide you with an IP, how do you handle the root domain in these cases? –  Kevin Jul 27 '12 at 0:04
    
Kevin, Route 53 has some additional features compared to traditional DNS hosting. One of them is the ability to create an "alias." So you create a normal A record for your root domain but rather than imputing an IP address, you choose "Alias: Yes" in the AWS Management Console and select your ELB. –  jamieb Jul 27 '12 at 2:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.