AWS Host Multiple Domains On One EC2 Instance

1.9k Views Asked by At

I have one EC2 instance running with an Elastic IP of 54.82.145.116. My vhost.conf file looks like this:

<VirtualHost *:80>
    ServerName default:80
    DocumentRoot /var/www/html/brentrichison.com
    ServerAdmin [email protected]
    ErrorLog /var/www/html/logs/error.log
</VirtualHost>

<VirtualHost *:80>
    ServerName brentrichison.com
    DocumentRoot /var/www/html/brentrichison.com
</VirtualHost>

<VirtualHost *:80>
    ServerName greyspace.io
    DocumentRoot /var/www/html/greyspace.io
</VirtualHost>

<VirtualHost *:80>
    ServerName tlsbaseball.com
    DocumentRoot /var/www/html/tlsbaseball.com
</VirtualHost>

<VirtualHost *:80>
    ServerName tm.brentrichison.com
    DocumentRoot /var/www/html/tm
</VirtualHost>

<VirtualHost *:80>
    ServerName tls.brentrichison.com
    DocumentRoot /var/www/html/tlsbaseball.com
</VirtualHost>

The first domain, brentrichison.com, works fine. The subdomains for that domain also work fine. The other domains, tlsbaseball.com and greyspace.io do not work at all.

Each domain has a Hosted Zone on Route 53. Each domain's "A" Record points to 54.82.145.116. Each domain has its own SOA Record, and each zone has its own DNS Records.

Does anyone have any ideas why my other two domains won't resolve? Thanks.

1

There are 1 best solutions below

3
On BEST ANSWER

I can see from the whois greyspace.io and tlsbasebll.com are pointed to Route53 servers, but they're not answering my queries. Look at the hosted zones in Route 53 and verify that the NS servers specified there are the ones from Amazon and line up with what you have in DNS. It's pretty easy to swap them or get them wrong when you're doing multiple domains.

$ whois greyspace.io

Domain : greyspace.io
Status : Live
Expiry : 2017-11-25

NS 1   : ns-1566.awsdns-03.co.uk
NS 2   : ns-1297.awsdns-34.org
NS 3   : ns-1021.awsdns-63.net
NS 4   : ns-343.awsdns-42.com
$ dig @ns-343.awsdns-42.com greyspace.io -t soa

; <<>> DiG 9.8.3-P1 <<>> @ns-343.awsdns-42.com greyspace.io -t soa
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 27079
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;greyspace.io.          IN  SOA

;; Query time: 26 msec
;; SERVER: 205.251.193.87#53(205.251.193.87)
;; WHEN: Sat Dec 24 10:19:01 2016
;; MSG SIZE  rcvd: 30

Based on your comment below, it sounds like you registered these domains with amazon, and then recreated the hosted zone a few times. Let's look a little closer at what that really looks like for, say, greyspace.io:

  1. register with amazon
    1. as dns provider, amazon automatically creates a hosted zone to serve the records associated with your domain, which generates the names of nameservers willing to answer queries for that domain
    2. as a registrar amazon saves the greyspace registration data within the .io registry, along with dns glue records that point requests for the domain to the AWS Route53 servers from step 1

Now the domain's dns hsoted zone is "live", in that the whois data points to it.

  1. you delete and recreate the dns hosted zone. Upon deletion, the listed nameservers aren't willing to answer these queries anymore, but they're still listed in DNS

So all you have to do is go into your domain registration and update the whois listed nameservers to point to the new ones you got when you recreated the hosted zone.

On an unrelated note, why do you have this in here twice?

<VirtualHost *:80>
    ServerName default:80
    DocumentRoot /var/www/html/brentrichison.com
    ServerAdmin [email protected]
    ErrorLog /var/www/html/logs/error.log
</VirtualHost>

<VirtualHost *:80>
    ServerName brentrichison.com
    DocumentRoot /var/www/html/brentrichison.com
</VirtualHost>

2 sites with the same docroot? I'm confused. Aren't those actually the same site?