nginx probably deliering wrong filetype for .css file with php tags
- by Katai
And again - NGINX is giving me many Questions today :)
Like always, I already tried around for a while, but cant seem to fix this issue:
I just configured NGINX to handle my .css files equal to my .php files (to parse PHP tags inside the CSS file). This works perfectly, and the file is found and delivered.
I could debug it with FIrebug, and everything is OK (it displays the contents of the .css inside the opened <link> tag). So, everything working, right? Wrong.
It has the CSS, but it does not interpret it! What I mean by this: apparently, the file-type of the CSS (or aplication-type, whatever) is wrong. The Page can access the CSS, but doesnt bother at all to actually use it.
What I checked / tried:
There are no PHP errors inside of the .css, so that one is out
The .css is accessible. I can call the URI manually, or check if the included URL finds it: both works
The .css has no syntax errors (i switched to a css that just has body {background-color: #000; }
It works whitout NGINX
I deleted the browser cache / restarted NGINX after config rewrites
Here the configuration:
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/board.access_log;
error_log /var/log/nginx/board.error_log warn;
root /var/www/board/public;
index index.php;
fastcgi_index index.php;
location / {
try_files $uri $uri /index.php;
}
location ~ (\.php|\.css)$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
#keepalive_timeout 0;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:7777;
}
}
Firebug 'Network' Response Header:
Connection keep-alive
Content-Encoding gzip
Content-Type text/html
Date Sat, 16 Jun 2012 10:08:40 GMT
Server nginx/1.0.5
Transfer-Encoding chunked
X-Powered-By PHP/5.3.6-13ubuntu3.7
I think I just answered my own question. Is the Content-Type text/html the problem? How can I remove that?
My personal guess is that I have to use this in some way
include /etc/nginx/mime.types;
default_type application/octet-stream;
But I'm not sure... anyone an idea how to solve this?
TLDR;
CSS file is delivered correctly, but it doesnt seem to be 'used' as CSS from the browser. (Tested, works on apache)