Ruben
Ruben

Reputation: 1091

css and images not recognized by nginx: Resource interpreted as Stylesheet but transferred with MIME type text/html

I'm trying to run Rainloop in a subdirectory. http://babylon/webmail. I get the css and js are not recognized. For example:

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://babylon/webmail/rainloop/v/1.10.5.192/static/css/rainloop/v/1.10.5.192/static/css/app.min.css?standard".

Some possible (but didnt work) solutions I tried:

  1. "include /etc/nginx/mime.types;" is found in nginx.conf.
  2. Some say, location for php is screwing up that part, so I should add this line:

    fastcgi_split_path_info ^(.+.php)(/.+)$; #this line

But still it doesn't work.

  1. I add new locations for css and javascript with root but also nothing.

My config is this one: (it is an included file)

location ^~ /webmail {
    root /srv/rainloop/public_html;
    try_files $uri $uri/ /webmail/index.php?$query_string;
    access_log /srv/rainloop/logs/access.log;
    error_log /srv/rainloop/logs/error.log;
    index index.php;
    access_log /var/log/nginx/scripts.log scripts;

    location ~ \.php$ {
        #if (!-f $request_filename) { return 404; }
        include fastcgi_params;
        #fastcgi_split_path_info ^(.+\.php)(/.+)$; #this line
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_FILENAME /srv/rainloop/public_html/index.php;
    }

    location ~ /\.ht {
        deny all;
    }

    location ^~ /webmail/data {
        deny all;
    }
}

Upvotes: 3

Views: 9854

Answers (5)

Amir Kaftari
Amir Kaftari

Reputation: 1524

Sometime with remove

<Document html>

from top of html file , everything well done. try it.

Upvotes: 0

Add these two lines to http {}

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

Upvotes: 0

shukebeta
shukebeta

Reputation: 101

Add the code block below into the appropriate location block:

types {
    text/css css;
}

Upvotes: 0

AMS777
AMS777

Reputation: 5969

I was having the same problem with CSS and Javascript files, that were being served as text/html. After trying everything I could think of during hours without any effect, it was automatically solved by restarting Chrome.

Upvotes: 0

Sanan Guliyev
Sanan Guliyev

Reputation: 761

I think that it can solve your problem.

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

Upvotes: 7

Related Questions