Setup Nginx Server Block (Part 2)

In our last post, we explained that if you want to handle more than one domain using Nginx, you need to set up the Nginx Server block. We also explained half of the steps so if you haven’t checked that out yet, here is the link:

We completed setting up the Nginx server block for the first domain so let’s go and setup the second server block.

Setup the second Nginx server block

We need to do the exact same thing for the second domain. There is only going to be one difference through this process and it’s that we need to remove default_server from the listen directory in config file. This is because we can only have one default_server or else the webserver won’t work.

There is a default server block in this path:


Now we copy the file with a new name based on the domain:

sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/

Then we need to edit the file:

sudo nano /etc/nginx/sites-available/

Scroll the file to find the “listen” section:

Edit file

Remove default_server from the “listen” section:

Find the root /var/www/html in the mentioned file and replace it with the path of the directory you made earlier. For example /var/www/

Now find the server_name _;  line and change the domain name. (You can search for this line using Ctrl+W)

Save the changes and close the file. (Use Ctrl+X then Y to save changes)

Just like the other one let’s make sure the Nginx config file exists:

sudo nginx -t

You should see this as a result:

You are done setting up the second Nginx server block.

Creating a Symbolic Link

Now we are going to create a symbolic link from sites-available in the sites-enabled directory. This will technically call the Nginx web server.

sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

Remove the symbolic link from the default server:

sudo rm /etc/nginx/sites-enabled/default

Restart Nginx:

sudo service nginx restart


Assuming that you have already done all the DNS configurations on the Domain side and it’s pointing to the Server‘s IP, you can see the test page on your browser.

Nginx Test Page

Hope you enjoyed this post if you did, you can visit our blog for more!

IP Address Classes

In an earlier post, we’ve explained about IP and IP Regions. In this post, we are going to explain about IP Address Classes.

As we’ve explained about IPs’ structure before,all IPv4 addresses have 4 octets. According to this fact, Network ID and Host ID are defined.

Network ID

All devices get an IP when they want to connect to a network. So, imagine you have 2 devices and their IP, how do you know if they are in the same network or not? the answer is : Network ID.

Network ID is the fixed octets of your IPs. for example: supposing that and are 2 IPs. The first two octets are identical and fixed for both IPs. So, both of these IPs are in the same network and their network ID is 172.16.

Host ID

Host ID is the variable octets in IPs. This means that considering the example IPs above ( , , 3.1 and 2.1 are the Host IDs of our IPs.

IPv4 Classes:

IPv4 classes

Class A: the first octet of these class of IP is fixed. This means that the first octet is Network ID and all the other octets are host ID.The octet range for this class is 1 to 126.

Class B: the first two octets of these class of IP are fixed. This means that the first two octets are Network ID and the other two octets are host ID. The octet range for this class is 128 to 191.

Class C: the first three octets of these class of IP are fixed. This means that the first three octets are Network ID and all the last octet is host ID. The octet range for this class is 192 to 223.

Class D: This class of IP is a special class which we use for multi-casting. Multi-casting is used when we want to send specific packets to specific stations. The octet range for this class is 224 to 239.

If you’ve enjoyed this post, visit our blog for more.