Wrong Content-Type

Hi list,

I’m having a content-type issue with nginx 0.7 on Debian Squeeze.

I have mime.types included in the “http” directive, but when requesting
CSS or Javascript file, the content type is set to text/html.
(the application is Roundcube 0.5 beta).

I have found a workaround by adding this in my server declaration:

 location ~ \.css {
     add_header  Content-Type    text/css;
 }

But it’s quite ugly. Is there any better way to fix this problem ?

Thanks,
Julien

On Fri, Dec 03, 2010 at 09:17:13AM +0100, Julien Vehent wrote:

 location ~ \.css {
     add_header  Content-Type    text/css;
 }

But it’s quite ugly. Is there any better way to fix this problem ?

Does nginx proxy these files or handle them as static files ?


Igor S.
http://sysoev.ru/en/

On Fri, Dec 03, 2010 at 10:16:34AM +0100, Julien Vehent wrote:

Static files stored in /var/www and owned by www-data (nginx process
owner). It’s the default debian configuration.

Php5 is fastcgi on a local tcp socket.
There is nothing wrong in error.log.

Are these CSS and JS files handled by PHP ?


Igor S.
http://sysoev.ru/en/

On 12/03/2010 10:20 AM, Igor S. wrote:

CSS or Javascript file, the content type is set to text/html.
Does nginx proxy these files or handle them as static files ?

Good catch ! I don’t know how I missed this, but I was sending ALL of
the static files to PHP…

My location was set like that:


location /roundcube {
client_max_body_size 100m;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}

I changed it to add the if constraint and it works fine now:

location /roundcube {
client_max_body_size 100m;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if ($uri ~ “.php”){
fastcgi_pass 127.0.0.1:9000;
}
}

On 12/03/2010 09:45 AM, Igor S. wrote:

I have found a workaround by adding this in my server declaration:

  location ~ \.css {
      add_header  Content-Type    text/css;
  }

But it’s quite ugly. Is there any better way to fix this problem ?

Does nginx proxy these files or handle them as static files ?

Static files stored in /var/www and owned by www-data (nginx process
owner). It’s the default debian configuration.

Php5 is fastcgi on a local tcp socket.
There is nothing wrong in error.log.

Julien

On Fri, Dec 03, 2010 at 11:17:57AM +0100, Julien Vehent wrote:

I have mime.types included in the “http” directive, but when requesting

Are these CSS and JS files handled by PHP ?
client_max_body_size 100m;
client_max_body_size 100m;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if ($uri ~ “.php”){
fastcgi_pass 127.0.0.1:9000;
}
}


This is wrong way to it: you should use just locations:

location /roundcube/ {
location ~ .php {
client_max_body_size 100m;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
}
}


Igor S.
http://sysoev.ru/en/