Serve Static Content

type
status
date
slug
summary
tags
category
icon
password

/srv Directory

This /srv directory is meant to contain site-specific data which is served by this system.
Now cd into this directory and clone the code repository that comes with this book:
The code is almost the same, except the return directive has now been replaced by a root directive.
This directive is used for declaring the root directory for a site.
By writing root /srv/nginx-handbook-projects/static-demo you're telling NGINX to look for files to serve inside the /srv/nginx-handbook-projects/static-demo directory if any request comes to this server.
Since NGINX is a web server, it is smart enough to serve the index.html file by default.

Static file type handling

When types {} or include /etc/nginx/mime.types; is not configured.
Please note the Content-Type and observe how it is displayed as text/plain instead of text/css .
This means that NGINX is serving the file as plain text instead of as a stylesheet.
You can also press F12 in the browser, go to check the Content-Type returned by the server for mini.min.css .

Reference article

Understand Directives And ContextsLocation Matches
Loading...
Catalog