How to use only subdomain in nginx

November 19, 2019 293 views
Nginx

I just purchased new domain name with DigitalOcean droplet

Let’s say my domain is abc.com,
i only want to access my website from test.abc.com

not from root, not from others.

Currently in DO, i set my DNS records like this:

A record - test.abc.com - myIP
AAAA record (for ipv6) - test.abc.com - ipv6address

  1. How should my nginx file looks like to use only that subdomain?
  2. Should i set DNS records for the root too? abc.com?

thanks

edited by bobbyiliev
1 Answer

Hello, @manhil

  1. The nginx configuration file should look like any other regular domain you have. You can still use the default configuration file as template.
  2. You don’t need to point the main domain itself - abc.com If test.abc.com is pointed to your droplet this is all you need.

Hope this helps!

Regards,
Alex

Have another answer? Share your knowledge.