Report this

What is the reason for this report?

How to use only subdomain in nginx

Posted on November 19, 2019

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



This textbox defaults to using Markdown to format your 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 - abc.com If test.abc.com is pointed to your droplet this is all you need.

Hope this helps!

Regards, Alex

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.