Need Assistance?

In only two hours, with an average response time of 15 minutes, our expert will have your problem sorted out.

Server Trouble?

For a single, all-inclusive fee, we guarantee the continuous reliability, safety, and blazing speed of your servers.

Add Subdomain With NGINX DigitalOcean

With the help of this article, adding a subdomain with NGINX in DigitalOcean became simple. With our DigitalOcean Support Services, Skynats can handle your DigitalOcean issues.

Adding a subdomain with NGINX in DigitalOcean

Nginx is one of the most widely used web servers in the world, hosting some of the busiest and greatest websites on the internet. It is a straightforward choice that can act as a reverse proxy, mail server, or web server. The most user-friendly method of configuring a fast, safe, and reliable NGINX server is through DigitalOcean’s NGINXConfig.

We’ll go over how to add a subdomain with NGINX on DigitalOcean in this article.


  • An Ubuntu server on DigitalOcean
  • NGINX and SSL on DigitalOcean 

Following are the steps:

  • Make an “A” record first for the subdomain.
  • Then make an index file and subdomain directory.
  • Make an NGINX server block for the subdomain as well.
  • For security, add an SSL certificate right away.
  •  Lastly, access the subdomain.

Let’s go over each step in detail.

1. Make an “A” record first for the subdomain:

Go to the DNS settings page to access the records that contain the primary domain DNS settings. Afterward, by including only the subdomain portion in the Enter Name field, add an A record with a subdomain.

2. Then make an index file and a subdomain directory:

Create the subdomain first, then add the index file.

# Create directory
sudo mkdir $subdomain_dir
# Create index.html
sudo touch $subdomain_dir/index.html

The contents of the index file can be modified. The content appears as follows:

<!DOCTYPE html>
<title>Welcome to Example Appstore!</title>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
<h1>Welcome to Example Appstore!</h1>
<p>This site is under active development.</p>

<h2>Related Websites</h2>
<a href = "">Datanovia</a><br/>

3. Make an NGINX server block for the subdomain as well:

The subdomain is now enabled on the NGINX server.

# 1. Copy the default subdomain configuration
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/$mysubdomain
sudo ln -s /etc/nginx/sites-available/$mysubdomain /etc/nginx/sites-enabled/$mysubdomain
# 2. Open the config file
sudo nano /etc/nginx/sites-available/$mysubdomain
# 3. Edit the file
# The content will look like this
server {
        listen 80;
        listen [::]:80;
        root /var/www/apps;
        index index.html;
# 4. Restart NGINX
sudo service nginx restart

4. For security, add an SSL certificate right away:

# Obtain an SSL Certificate
sudo certbot --nginx -d $mysubdomain

5. Lastly, access the subdomain:

Go to the subdomain at this point.


In this article, we offer a straightforward technique developed by our tech team for adding a subdomain with NGINX in DigitalOcean.

Are you looking for an answer to another query? Contact our technical support team.

Liked!! Share the post.

Get Support right now!

Start server management with our 24x7 monitoring and active support team

Can't get what you are looking for?

Available 24x7 for emergency support.