Forum: NGINX windows static assets - solved

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8072fdc83f765ae5075f252cb4d4d111?d=identicon&s=25 Chris Cortese (Guest)
on 2009-05-15 03:45
(Received via mailing list)
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;
  }
}
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-05-15 07:25
(Received via mailing list)
On Thu, May 14, 2009 at 06:33:59PM -0700, Chris Cortese wrote:

> 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).

Actually in nginx/Windows root is relative to the directory where nginx
was run.

>  error_log  logs/jobsite.error.log;
>
>  root ../cygwin/home/Chris/www/live/jobsite/trunk/html/public;  # this

Does not this work:

  root C:/cygwin/home/Chris/www/live/jobsite/trunk/html/public;

?
8072fdc83f765ae5075f252cb4d4d111?d=identicon&s=25 Chris Cortese (Guest)
on 2009-05-15 08:45
(Received via mailing list)
Actually that does work.  Now I'm stumped as to what was the original
problem because I'm pretty sure I had that at one point.  At least it's
solved now.
This topic is locked and can not be replied to.