How to serve static HTML files using NGINX

My html folder structure is as below. this is located in /var/www folder

html/
├── index.html
├── index.nginx-debian.html
├── one.html
└── sub
    └── one.html

To serve these files using NGINX, you can use following NGINX configurations. I have given two version and both works. First version is using root directive and second is by using alias directive. personally, i prefer alias as it easy to understand.

server {
    listen 80;
    server_name staticweb.com;

  # access_log /var/log/nginx/staticweb_access.log;
  # error_log  /var/log/nginx/staticweb_error.log;

    location / {
        root /var/www/html;
        index index.html;
        try_files $uri $uri/ =404;
    }

    location /sub/ {
        root /var/www/html;
        index index.html;
        try_files $uri $uri/ =404;
    }

}

Here is another version using alias. Please note here you dont need to add "/" after sub in location block

server {
    listen 80;
    server_name staticweb.com;

  # access_log /var/log/nginx/staticweb_access.log;
  # error_log  /var/log/nginx/staticweb_error.log;

    location / {
        root /var/www/html;
        index index.html;
        try_files $uri $uri/ =404;
    }

    location /sub {
        alias /var/www/html/sub;
        index index.html;
        try_files $uri $uri/ =404;
    }

}