How to add subdomain from different provider to work with virtual host?

June 8, 2015 942 views
Apache DNS Configuration Management Ubuntu

I have domain and hosting in different company I need to host subdomain on DO droplet and it should work as virtual host. I just can't figure out DNS settings.
In domain parking company I set subdomain pointing to droplet IP. I added Apache Virtual host file and have enabled it.

If I go to this subdomain it shows same index file as default html (the same if I go to droplet IP address).

This is my zone file

$TTL 1800 IN SOA 1433712271 10800 3600 604800 1800 1800 IN NS 1800 IN NS 1800 IN NS 1800 IN A 1800 IN A

My Virtual host file

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

What I'm doing wrong?

P.S. I redirected other domain (not subdomain) to same droplet, added virtual host settings and it works perfect. Then I added subdomain for same domain, once again works perfect. So I assume that redirected subdomain dns records should be different?

Thanks in advance!

  • I am a bit confused by your DNS settings. If your domain is on another host and you simply want to point a subdomain to your droplet you only need to add an A record. There is no need for NS records as this domain would not be using DO's DNS services. Aside from that, this configuration should work correctly.

  • you might reconsider using

    not that it has anything to do with your current problem, but it has an unpleasant meaning in some languages...unless that was your intent.

  • @ryanpq : I removed NS and left record A with @ and latter with ca and IP. Does not work.
    @sierracircle : It just happened with no intend. And my intent is just to have ca. Thanks for your concern :)

  • create A record and point to your DO droplet IP. Then, try follow these steps

    by Justin Ellingwood
    The Apache web server is the most popular way to serve web content on the internet. Apache has the ability to serve multiple domains from a single server by using a mechanism called "virtual hosts". If a virtual host is configured correctly for each domain, the web server can correctly route traffic to the appropriate files based on the domain name requested. In this guide, we'll demonstrate how to configure Apache virtual hosts on an Ubuntu 14.04 VPS.
Be the first one to answer this question.