oguerra
By:
oguerra

droplet for subdomain of domain hosted elsewhere

April 26, 2017 103 views
DNS Debian

Hi,

I already read https://www.digitalocean.com/community/questions/set-my-droplet-to-be-a-subdomain-of-a-domain-hosted-on-a-different-server but I have more questions.

I have a droplet that I want it to respond to requests made to a subdomain sucha as subdomain.domian.com

domain.com is hosted elsewhere, so name servers are not DO's, but are the name servers of the hosting provider.

I named the droplet with FQDN, so PTR record exists.

I created the A record at the hosting DNS manager, pointing to droplet IP. That was 21 hours ago. I guess that is enough time for propagation, specially if no name servers were changed.

"# host subdomain.domain.com ns1.digitalocean.com" returns 5 (refused)

I don't know if a have to add a domain to the droplet even if the name servers are not DO's. No tutorials or community questions answer this.

So I added the domain to the droplet, and changed the NS records to point to the hosting name servers. Don't know if this requires propagation time as well. I did this 2 hours ago.

"# host subdomain.domain.com ns1.digitalocean.com" now returns 3 (NXDOMAIN). Same result if using the hosting name servers.

The droplet already has an nginx server running.

I already powered off and on the droplet.

Don't know what is missing or incorrect.

Please help.

Best Regards.

1 Answer

@oguerra

When adding an A entry, it should look something like:

A        sub        DROPLET_IP

Once the sub-domain A entry exists, you'd need to setup a proper server block for the sub-domain by either modifying the default server block or creating a new one, then restart NGINX for the changes to take.

The default server block for NGINX can be found here:

/etc/nginx/sites-available/default

Within the above file, you'll see server_name, which what you'd modify.

server_name sub.domain.com www.sub.domain.com;

You'll also want to modify root to tell NGINX where to find the files you're uploading and want to use for the sub-domain.

Beyond that, what else needs to be modified depends on what you're trying to setup (PHP, NodeJS, Python, etc).

Have another answer? Share your knowledge.