Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Host Multiple Domains On One EC2 Instance

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.

like image 691
Brent Avatar asked Dec 24 '16 16:12

Brent


People also ask

Can we host multiple websites on one EC2 instance?

If you have more than one website, you can host them in IIS on the same EC2 Windows Server instance. IIS differentiates between websites by using bindings, which are a combination of the protocol type, IP address, port, and hostname. To avoid IP and port conflicts, you must add a hostname.

Can an EC2 instance have multiple subnets?

Using this solution, you can place instances launched by EC2 Auto Scaling in two different subnets of your choice. For example, you can have one elastic network interface in a public subnet and the other in a private subnet.

Can EC2 instance have multiple IPS?

Classic EC2 instances can only have a single Elastic IP address associated with them. To get multiple IP addresses, you must use VPC and setup multiple network interfaces on your instance.


1 Answers

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?

like image 163
Daniel Farrell Avatar answered Sep 21 '22 06:09

Daniel Farrell