0

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.

1
  • Welcome to Server Fault! Please post your current nginx configuration. Even if it isn't working. Commented Jan 27, 2022 at 13:56

1 Answer 1

1

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.

1
  • Thanks, mate! The kind of information I was looking for! Commented Jan 28, 2022 at 7:53

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.