nginx proxy static website css parsing exception

Today, when using ecs to deploy web pages, a problem occurred. Using nginx to proxy to the page index.html path, all resources in the same path can be loaded, but the page style cannot be loaded correctly. Open f12, there is no resource abnormality in the network and console, but the page is messed up.
It is normal to open locally, but not on the server?
When I used nginx before, there was no such problem, so I guess whether the new version of nginx has modified the configuration parameters?
But I looked through the documentation of nginx, but I couldn't find it. So I followed the symptoms and began to read the text on the Internet, and finally:

Solution

If you do not configure css file parsing, nginx defaults to text/plainparsing all types of files, so we need to make a simple configuration for this. Put the following piece of code locationunder the module and restart nginx. Remember to clear your browser's cache .

include mime.types;  
default_type application/octet-stream;

Complete as follows:

location / {
    
    
              include mime.types;
              default_type application/octet-stream;
              alias /opt/website/;
              autoindex on;
         }

Guess you like

Origin blog.csdn.net/w_monster/article/details/128821604