windows static assets - solved

Chris Cortese cortese.consulting at gmail.com
Fri May 15 05:33:59 MSD 2009


I finally found the solution to my problem with getting 404 on static 
assets (/images, /js, /css).

Not sure how I missed it before but I saw the problem in the error log 
now.  Basically  I was not understanding that the root path needed to be 
relative to the location of the nginx.exe (c:\nginx\nginx.exe).

Changing "/cygwin/..." to "../cygwin/..." was my solution.  I didn't 
have a problem with the non-static stuff (PHP) because all of that was 
handled by fastcgi, which expected the full windows path 
("c:/cygwin/...").  Below is my working config.

server {
  listen   *:80;
  server_name  jobsite.xpdesktop;

  access_log  logs/jobsite.access.log;
  error_log  logs/jobsite.error.log;

  root ../cygwin/home/Chris/www/live/jobsite/trunk/html/public;  # this 
was the fix
  index index.php index.html;

# serve static files directly
  location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|pdf|zip|tar|gz|bz|bz2)$ {
  }

  location / {
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME 
c:/cygwin/home/Chris/www/live/jobsite/trunk/html/public/index.php;
    fastcgi_param QUERY_STRING      q=$request_uri;
    include fastcgi_params;
  }

  location ~ /.php$ {
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME 
c:/cygwin/home/Chris/www/live/jobsite/trunk/html/public$fastcgi_script_name;
    fastcgi_param QUERY_STRING      q=$request_uri;
    include fastcgi_params;
  }

  location = /css/style.php {
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME 
c:/cygwin/home/Chris/www/live/jobsite/trunk/html/public/css/style.php;
    include fastcgi_params;
  }
}






More information about the nginx mailing list