Search code examples
amazon-web-servicesapache2.4namecheap

Having trouble setting up subdomain hosted on AWS, through NameCheap


I bought a cheap domain on Namecheap. It is hosted on an AWS EC2 Linux Ubuntu instance. I set it up through Route 53. The root domain works correctly.

What I'm trying to do is get a subdomain working, such as apex.rootdomain.com, and I am having much more trouble than I thought. I figured it would be much easier than setting up the root domain (which was actually pretty simple due to a great article I found).

Here is my apache2.conf:

<Directory /html/root>
        Options FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

<Directory /html/apex>
        Options FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

Here is my config file in etc/apache2/sites-available/MyConfig.conf:

<VirtualHost *:80>

        ServerAdmin webmaster@localhost
        DocumentRoot /html/root
        ServerName www.root.com
        ServerAlias root.com

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:80>
        ServerName apex.root.com
        DocumentRoot "/html/apex"
</VirtualHost>

I believe that My apache2.conf and MyConfig.conf are both correct , because they work for my main domain.

Here is how I set up the subdomain on Route 53:

  1. I created a hosted zone for my subdomain.
    • This resulted in NS and SOA records sets.
  2. I then went to the hosted zone for my main domain name.
  3. I created a new NS record for apex.root.com in the hosted zone of root.com
  4. I copied and pasted the 4 addresses from step (1) into the record set in step (3)
  5. I copied and pasted the addresses from (4) into the 'Name Servers' in my Namecheap dashboard. I now have a total of 8 Name Server addresses in Namecheap (4 for root domain, 4 for subdomain)

Edit

Just to add, I waited about 2 or 3 days just to see if the issue would resolve itself, but it has not. Namecheap said that it takes less than 48 hour for changes to take effect.

EDIT: ZONE FILE

Hosted zone for root.com

NAME                               TYPE    VALUE
root.com.                            A      Elastic-IP


root.com.                            NS   Domain-Name-A.
                                          Domain-Name-B. 
                                          Domain-Name-C. 
                                          Domain-Name-D.

root.com.                           SOA   some values that I don't think matter

www.root.com.                         A   Elastic-IP
apex.root.com                         A   Elastic-IP

Name Servers: Domain-Name-A, Domain-Name-B, Domain-Name-C, Domain-Name-D, Domain-Name-E, Domain-Name-F, Domain-Name-G, Domain-Name-H are listed as 'Name Servers' on Namecheap.

Here is what my Namecheap setup looks like:

NameServers

Customs DNS
- Domain-Name-A
- Domain-Name-B     
- Domain-Name-C
- Domain-Name-D  

Solution

  • Assuming root.com and www.root.com work in your current config, it would be as follows:

    root.com.                            A      Elastic-IP
    www.root.com.                        A      Elastic-IP
    apex.root.com.                       A      Elastic-IP
    

    keeping in mind that on GoDaddy for your DNS it would be as follows:

    @                                    A      Elastic-IP
    www                                  A      Elastic-IP
    apex                                 A      Elastic-IP