Score:0

Suggestions for using Nginx web server on Ubuntu 20.04

bs flag

We recently switched to Ubuntu 20.04 from Windows, and I am here to seek suggestions and recommendations for my use case.

I have installed Nginx web server on my Ubuntu VM (my_server_name) and we would like to serve several HTML files via Nginx to display in a front-end application. The HTML files content is mainly based on maps and animations, and some HTML files also have associated JS and CSS files. There can be many concurrent users of the front-end app at the same time.

Several Nginx tutorial links over the Internet recommends creating server blocks. My question is, do I need server blocks for my use case? or is it appropriate to dump all HTML files inside /var/www/html directory to display in front end app?

I have checked Nginx wiki and docs for optimization and tuning tips, but would very appreciate and welcome suggestions and recommendations for my use-case scenario.

Paul avatar
cn flag
Welcome to Server Fault! Please post your current nginx configuration. Even if it isn't working.
Score:1
cn flag
Bob

Several Nginx tutorial links over the Internet recommends creating server blocks. My question is, do I need server blocks for my use case?

A server block in nginx is the method to configure nginx to respond differently whenever requests arrive that either use a different port and/or do or do not use TLS encryption and/or contain different Host: headers.

In other words: when for example www.example.com and api.example.org point to the same nginx instance and requests for http://www.example.com or https://api.example.org need to show different content, then you need server blocks for each.

Server blocks are also commonly used to ensure that content only shows when people make requests when visiting your domain and that requests with only your IP-address, or an ISP assigned hostname, or any other random domain won't display your brand and content. See: http://nginx.org/en/docs/http/request_processing.html

Server blocks can be omitted when you don't need such behaviour, but most people still set one up to keep their configuration tidy and future proof.

is it appropriate to dump all HTML files inside /var/www/html directory to display in front end app?

You might organise your content over some more subdirectories but up until a couple of thousand files a single flat directory won't be harmful.

khajlk avatar
bs flag
Thanks, mate! The kind of information I was looking for!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.