0

Somehow nginx can't load CSS files and result website showing with no CSS.

In Firefox I got those warning:

The stylesheet http://192.168.1.10:6000/templates/main/css/layout.css was not loaded because its MIME type, "text/html", is not "text/css".

The stylesheet http://192.168.1.10:6000/templates/main/css/jqevent.css was not loaded because its MIME type, "text/html", is not "text/css".

The stylesheet http://192.168.1.10:6000/templates/main/css/crud.css was not loaded because its MIME type, "text/html", is not "text/css".

Nginx Conf

user  root;

http {

    include       /home/school/webapp/nginx/conf/mime.types;

    default_type  application/octet-stream;


    server {
        listen 6000;
        index index.php index.html index.htm;
        root /home/school/webapp/wwwdir/;

               location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

    }
}
Puck
  • 2,080
  • 4
  • 19
  • 30
Krasic
  • 137
  • 2
  • 14
  • This link might help you: http://stackoverflow.com/questions/29573489/nginx-failing-to-load-css-and-js-files-mime-type-error – Bogdan Nov 08 '15 at 17:55
  • no luck , i already spent 3 days trying to solve it and reading... i also visited that thread but didnt succeed yet... – Krasic Nov 08 '15 at 18:08
  • but is the nginx conf you provided complete? because if it is, I don't see any css specific conf. – Bogdan Nov 08 '15 at 19:02
  • http://stackoverflow.com/questions/10075304/nginx-fails-to-load-css-files ----- This is similar to your case .....you can also try changing your default type as well....to **/etc/nginx/mime.types** from **application/octet-stream;** – sagarthapa Nov 08 '15 at 20:11
  • @Bogdan , why i should specific css conf ? . sagarthapa , i tried no luck... – Krasic Nov 09 '15 at 06:59
  • Because it is the css files that are sent with the wrong html header, so just like the link explains, you force the header for your css files. – Bogdan Nov 09 '15 at 07:20
  • i dont use default.conf ? i only use nginx.conf.. , i have added location ~ \.css { add_header Content-Type text/css; } location ~ \.js { add_header Content-Type application/x-javascript; } . but still no css affected.. , in all my programming years i never faced a problem with that kind sincerely now nearly 5 days and still not solved... – Krasic Nov 09 '15 at 07:44
  • Finally problem fixed it was a rewrite url line which caused the issue... thanks everyone – Krasic Nov 10 '15 at 12:34

1 Answers1

0

You should include mime types in your nginx.conf. See default nginx.conf here : https://www.nginx.com/resources/wiki/start/topics/examples/full/

Simply add below line include in location /

include conf/mime.types;

Rom1
  • 11
  • 3