How to use only subdomain in nginx

  • Posted November 19, 2019
  • Nginx

I just purchased new domain name with DigitalOcean droplet

Let’s say my domain is, i only want to access my website from
not from root, not from others.

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

A record - - myIP AAAA record (for ipv6) - - ipv6address

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



Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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 - If is pointed to your droplet this is all you need.

Hope this helps!

Regards, Alex