We migrated our web servers to Nginx mainly for performance reason, flexibility and ease of configuration (In this regard, a great load of satisfaction!).

However, only one site showed a strange behavior: it loads in its <head> a CSS

<link type="text/css" rel="stylesheet" href="/css/appli-test-local/appli.css">

and Firefox refuses to load the CSS file, complaining that the mime type is not css

The stylesheet http://client...com/css/appli-test-local/appli.css was not loaded because its MIME type, "text/html", is not "text/css".

while removing the dashes - works

<link type="text/css" rel="stylesheet" href="/css/applitestlocal/appli.css">

Nginx config

Regarding the Nginx config, its has been checked several times, against the numerous examples on the Net, the mime.types file contains

text/html                             html htm shtml;
text/css                              css;

and the nginx.conf for the main part

http {
  include    /etc/nginx/mime.types;
  include    /etc/nginx/fastcgi.conf;

  default_type application/octet-stream;

Is it likely to be a bug in Nginx having a hard time with dashes? Nginx being a well written piece of software, I'd be surprised, but it could be. Do I miss something obvious?

The problem happens only in Firefox, because FF does care about the mime types (which is a good thing!).

  • please post your nginx version, and dont forget to restart after change nginx configuration. and clear browser cache. – user58857 Nov 1 '10 at 14:10
  • Version 0.7.67. – Breaking not so bad Nov 1 '10 at 14:35

If you installed Nginx through your default distro repo then you're most likely using a very outdated version of Nginx which might very well contain such a bug.

For testing you should try either finding an updated repo or compiling the latest version from source. If that does not help then paste server OS and whole config file.

  • That was not the problem. I compiled the latest nginx, and the problem was still there. – Breaking not so bad Aug 24 '12 at 2:39

I compiled the latest nginx at the time, and the problem was still there. It seems it is a nginx bug in the path / regexp parsing that doesn't handle well dashes.

No relevant answer, so I'll accept this one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.