You are not logged in.

#1 2012-03-29 21:13:44

nXqd
Member
Registered: 2010-07-01
Posts: 173

nginx always handle css as text/plain

My nginx doesn't work well, it always handle css as text/plain. This result no-styling page ;(

My nginx config: http://pastebin.com/tRjEp8gP

user http;
worker_processes 1;

error_log /var/log/nginx/error.log;

events {
worker_connections 4096;
}

http {
#include /etc/nginx/mime.types;
access_log /var/log/nginx/access.log;

sendfile on;
keepalive_timeout 65;
tcp_nodelay on;

gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";

server {
access_log /var/log/nginx/localhost.access.log;

listen 80;
server_name localhost;
root /srv/http;

## Default location
location / {
index index.php index.html;
}

## Images and static content is treated different
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
access_log off;
expires 30d;
}


location ~ ^(.+\.php)(.*)$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; 
fastcgi_index index.php;

fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
}

## Disable viewing .htaccess & .htpassword
location ~ /\.ht {
deny all;
}

}#end server

} #end http

Thanks for reading my post,

Last edited by nXqd (2012-03-29 21:15:55)


When you live for a strong purpose, then hard work isn't an option. It's a necessity. - Steve Pavlina
dotFiles

Offline

#2 2012-03-29 22:27:16

Cdh
Member
Registered: 2009-02-03
Posts: 1,098

Re: nginx always handle css as text/plain

Google says

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

But it is probably a good idea to research how the mime types are normally set and search for a reason they are set wrong in your case...


฿ 18PRsqbZCrwPUrVnJe1BZvza7bwSDbpxZz

Offline

#3 2012-03-30 06:07:34

pshevtsov
Member
From: Novosibirsk, Russia
Registered: 2011-01-20
Posts: 52

Re: nginx always handle css as text/plain

Hello nXqd,

Just remove # before include /etc/nginx/mime.types;

Hope that helps

Offline

#4 2012-03-30 06:11:24

nXqd
Member
Registered: 2010-07-01
Posts: 173

Re: nginx always handle css as text/plain

Thanks both of you for your solution.
@pshevtsov: Yes this work, and mime.types is /etc/nginx/conf/mime.types.

But I just finally move all of my document to the root to make all css all working (localhost/index.php) . If I move it to serparate folder ( localhost/c5/index.php for example ), it doesn't work, how can I fix this ?


When you live for a strong purpose, then hard work isn't an option. It's a necessity. - Steve Pavlina
dotFiles

Offline

Board footer

Powered by FluxBB