The deployment of static content is always limited to the types of transmitted content, including CSS or JS, they also need to be declared for nginx to understand and allow access rights.
To deploy to allow users to access and use css files, let's refer to the following example
events {
}
http {
types {
text/html html;
text/css css;
}
server {
listen 80;
server_name nglearns.test;
root /srv/nglearns/demo;
}
}
Here we use context types immediately after the http block to specify the types of files that are allowed to be used.
By writing text/css css, you will help nginx understand and allow access to files with type text/css corresponding to files with extension css in the application folder.
Check with the following command
curl -I http://nglearns.test/demo.css
If there is a demo.css file in the application folder, we will get the following result
# HTTP/1.1 200 OK
# Server: nginx/1.18.0 (Ubuntu)
# Date: Wed, 21 Apr 2021 12:29:35 GMT
# Content-Type: text/css
# Content-Length: 46887
# Last-Modified: Wed, 21 Apr 2021 11:27:06 GMT
# Connection: keep-alive
# ETag: "60800c0a-b727"
# Accept-Ranges: bytes
So we have successfully deployed files with different formats in the system