Nginx – Wrong CSS mime type with Roundcube 0.5 beta and nginx

debiannginxroundcube

I'm running into a CSS problem. This is a setup based on Debian Squeeze (nginx/0.7.67, php5/cgi) on which I installed the latest Roundcube 0.5 beta.

PHP is properly processed, login works fine but the CSS files are not loaded and Firefox is throwing the following errors:

Error: The stylesheet
https://webmail.example.net:10443/roundcube/skins/default/common.css?s=1290600165

was not loaded because its MIME type,
"text/html", is not "text/css". Source
File:
https://webmail.example.net:10443/roundcube/?_task=login
Line: 0

Error: The stylesheet
https://webmail.example.net:10443/roundcube/skins/default/mail.css?s=1290156319

was not loaded because its MIME type,
"text/html", is not "text/css". Source
File:
https://webmail.example.net:10443/roundcube/?_task=login
Line: 0

As far as I understand, nginx doesn't see the .css extension (because ofthe ?s= argument) and thus set the mime type with the default value, being text/html.

Should I fix this in nginx (and how ?) or is it roundcube's related ?

Edit: It seems that it's nginx related. The content-type isn't set for any other type than text/html.
I had to include manually the following declarations to force CSS and JS content-types. That's ugly, and I never had the problem before… any idea ?

location ~ \.css {
    add_header  Content-Type    text/css;
}
location ~ \.js {
    add_header  Content-Type    application/x-javascript;
}

Best Answer

Same for me, Mime types are correct, but after I used this

location ~ \.css {
    add_header  Content-Type    text/css;
}
location ~ \.js {
    add_header  Content-Type    application/x-javascript;
}

I get a 404 not found error, remove that code, the css shows up fine, but fire fox won't load it due to wrong mime type

I'm on Nginx 0.9.3

FOund the problem! Looks like We we're running everything through PHP Processor Adding this:

if ($uri ~ "\.php"){
fastcgi_pass php-fpm;
}

In the location ~ ^\.php$ { section worked for me! Thanks!