Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
340 views
in Technique[技术] by (71.8m points)

Nginx is not loading .min files

I am facing a problem, normal CSS and js files are working normally, whereas the .min.js .min.css files are not being read by NGINX.

The issue isn't about permissions since NGINX is able to enter the directory but can not read : Failed to load resource the server responded with a status of 404 (Not Found) Note: All the scripts .js .css are being cached by the browser and nginx while the .min are not.

This is the config file :

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html/web;
    index index.php  index.html index.htm;
access_log /var/log/nginx/web.access.log;
error_log  /var/log/nginx/web.error.log debug;

location ~ /(index.php/)?admin((/)|(/([^/]+)/?)*)$
    {
         #return 200 $request_uri;
        root /var/www/html/web;
         try_files $uri $uri/ /index.php?/$request_uri;
         server_name_in_redirect off;
    }
    location ~ /(index.php/)?webroot/ <--- *** This is the folder that contains everything related to css js scripts etc .. All of the webroot files and loading except .min and other scripts***
   {
       root /var/www/html/web;
        try_files $uri /index.php?/$request_uri;
        server_name_in_redirect off;
    }
 location ~ /(index.php/)?reset_password((/)|(/([^/]+)/?)*)$
    {
         #return 506;
         try_files $uri /index.php?/$request_uri;
         server_name_in_redirect off;
    }

location ~ /(index.php/)?verify_email((/)|(/([^/]+)/?)*)$
    {
         try_files $uri /index.php?/$request_uri;
         server_name_in_redirect off;
    }
}

Edit : When I try to enter any route what so ever for example the reset password:

GET /webroot/theme_assets/global/plugins/websitePlugins/dist/css/style.css net::ERR_ABORTED 404 (Not Found)
reset_password:35 GET GET 

If I put the link for a normal js and CSS file in the browser, it redirects normally to the file and shows it on the page, while if I put the route to a .min file it gives 404

This is an error log example:

"/var/www/html/web/webroot/theme_assets/global/plugins/mt-includes/js/website.min.js.map" failed (2: No such file or directory), client: 91.232.101.42, server: , request: "GET /webroot/theme_assets/global/plugins/mt-includes/js/website.min.js.map

"/var/www/html/priceswitcherweb/favicon.ico" failed (2: No such file or directory)

 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /webroot/theme_assets/global/plugins/mt-includes/js/website.assets.min.js.map HTTP/1.0"

.min files are being treated as text/html not app/js , this is because nginx is not reaching those files , although the route is right and mime types too.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...