Configuring Multiple Websites in Nginx Web Server

NGINX is open-source web server software used for reverse proxy, load balancing, and caching. It provides HTTPS server capabilities and is mainly designed for maximum performance and stability. It also functions as a proxy server for email communications protocols, such as IMAP, POP3, and SMTP.
Step 1 : Install Nginx
Update system's package
sudo apt update

Install nginx package
sudo apt-get install nginx

Start & Restart the nginx service
sudo service nginx start
sudo service nginx restart

Check the nginx status
sudo service nginx status

Enable the nginx service
sudo systemctl enable nginx

2.Configure Nginx
Create folder for website 1 & 2
sudo mkdir -p /var/www/html/web1
sudo mkdir -p /var/www/html/web2

change the ownership for that two sites folders.
sudo chown -R $USER:$USER /var/www/html/web1
sudo chown -R $USER:$USER /var/www/html/web2

Create the index html file in webserver 1 & 2
vi /var/www/html/web1/index.html

vi /var/www/html/web2/index.html

Create the site configuration file for site 1 & 2 in sites-availabe folder and add the below content on it.
sudo vi /etc/nginx/sites-available/web1.conf
server
{
listen 80;
listen [::]:80;
root /var/www/html/web1;
index index.html index.htm index.nginx-debian.html index.php login.html;
server_name site1.dineshcloud.in www.site1.dineshcloud.in;
}

sudo vi /etc/nginx/sites-available/web2.conf
server
{
listen 80;
listen [::]:80;
root /var/www/html/web2;
index index.html index.htm index.nginx-debian.html index.php login.html;
server_name site2.dineshcloud.in www.site2.dineshcloud.in;
}

Enable the websites 1 & 2 which is we want to publish to public.
sudo ln -s /etc/nginx/sites-available/web1.conf /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/web2.conf /etc/nginx/sites-enabled/

Modify the default web root permission.
sudo chmod -R 755 /var/www/html/

Verify our configuration made on nginx is corrcet.
sudo nginx -t

Restart the nginx service
sudo service nginx restart

Check the nginx status
sudo service nginx status

Step 3 : Create A record for both sites :
I have domain in GoDaddy. Need to login GoDaddy account.
Create A record for site 1

Create A record for site 2

Now, check the sites are working or not
Site 1

Site 2

Now, successfully configured multisite in Nginx web server.