Forum: NGINX static images 404 on Windows

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.
Chris Cortese (Guest)
on 2009-05-09 12:35
(Received via mailing list)
OK so I've tried everything I can think of on this one.

Running 0.7.55 on both Ubuntu Jaunty and XP.  Jaunty works just fine.
On the Jaunty config, I do use rewrite to remap my js and css, but my
location /images/ directive is identical on Jaunty and XP, and the
latter 404's.

On XP, I can't get any of my static assets (/images, /css, /js) to load,
all 404.  /css/style.php (see conf below) works fine as does all .php
code.  This is a codeigniter site which explains the handling of
index.php.

Note that I have web source under /cygwin for my convenience only but I
am not using any cygwin components in my stack, all native Windows
components.

Here's my latest version of the XP 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;
  index index.php index.html;

  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 ~ (jpg|jpeg|gif|png)$ {
  }

  location /images/ {
    expires    30d;
  }

  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;
  }
}
raptium (Guest)
on 2009-05-12 08:36
(Received via mailing list)
> Note that I have web source under /cygwin for my convenience only but I am
> not using any cygwin components in my stack, all native Windows components.

>  root /cygwin/home/Chris/www/live/jobsite/trunk/html/public;
>  index index.php index.html;

Since you are not using cygwin, I don't think
/cygwin/home/Chris/www/live/jobsite/trunk/html/public is a valid path
on windows, maybe you should change it to c:/cygwin... ?
Chris Cortese (Guest)
on 2009-05-12 08:43
(Received via mailing list)
thanks, I thought about that but the root path is working fine for the
.php ... just not the /public/css, /public/images, /public/js ...
Igor S. (Guest)
on 2009-05-12 10:24
(Received via mailing list)
On Mon, May 11, 2009 at 09:36:22PM -0700, Chris Cortese wrote:

> thanks, I thought about that but the root path is working fine for the
> .php ... just not the /public/css, /public/images, /public/js ...

 location ~ (jpg|jpeg|gif|png)$ {
    root c:/cygwin/home/Chris/www/live/jobsite/trunk/html/public;
 }

If php is cygwin application it requires cygwin style paths
"/cygwin/...",
Native applications require usual win32 paths: "c:/cygwin/...".
Chris Cortese (Guest)
on 2009-05-12 11:25
(Received via mailing list)
thanks...

it seems for me I just cannot trigger anything in that block.

Anybody see anything wrong?

Can there be a good way to debug which location directive is
processing??

  location ~ (jpg|jpeg|gif|png)$ {
    root c:/cygwin/home/Chris/www/live/jobsite/trunk/html/public;
#anything -- never gets here
  }
Igor S. (Guest)
on 2009-05-12 11:30
(Received via mailing list)
On Tue, May 12, 2009 at 12:16:25AM -0700, Chris Cortese wrote:

> #anything -- never gets here
>  }

Only debug log:

./configure --with-debug ...
error_log  /path/to/log  debug;

You will see

test location ...
test location ...
test location ...
using location ...
"坏人" (Guest)
on 2009-05-13 00:43
(Received via mailing list)
第一次见问题这么多的配置
location / {这个放那么靠上的位置,后面的location怎么用?
另外静态的图片不推荐用location ~ (jpg|jpeg|gif|png)$ {这种方式

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,1888,1919#msg-1919
Chris Cortese (Guest)
on 2009-05-13 01:00
(Received via mailing list)
thank you for replying.  I was starting to wonder if the email went
through.

Unfortunately, I cannot read it.  Can anybody translate for me?  Thanks
again.

Chris
"凌晨" (Guest)
on 2009-05-13 01:05
(Received via mailing list)
静态文件的配置在上,动态的在下。如果弄反了,静态配置根本不生效

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,1888,1924#msg-1924
raptium (Guest)
on 2009-05-13 01:10
(Received via mailing list)
2009/5/12 "坏人" <removed_email_address@domain.invalid>:
> 第一次见问题这么多的配置
Trans: First time to see a config with some many problems...


> location / {这个放那么靠上的位置,后面的location怎么用?
Trans: location / is on the top, so how can the following locations be
used?


> 另外静态的图片不推荐用location ~ (jpg|jpeg|gif|png)$ {这种方式
Trans: I don't recommend to use location ~ (jpg... $ for serving static
images.
Chris Cortese (Guest)
on 2009-05-13 01:25
(Received via mailing list)
raptium wrote:
> Trans: location / is on the top, so how can the following locations be used?
>
>
>
>> 另外静态的图片不推荐用location ~ (jpg|jpeg|gif|png)$ {这种方式
>>
> Trans: I don't recommend to use location ~ (jpg... $ for serving static images.
>
ok thanks.  What is the best way though?  I cannot get static assets on
the Windows side (necessary for me to see what the Windows world looks
like).
"坏人" (Guest)
on 2009-05-13 05:10
(Received via mailing list)
麻烦把你的各种信息发出来
包括主目录、各种静态文件的目录结构、以及说明下fastcgi实现的方式。

我的部分配置。基于centos+nginx+apache+php
  server {
    listen       80;
    server_name  www.abc.com;
    index index.htm index.php;
    root /data/sites;

    location ~* ^.+\.(jpg|jpeg|gif|png|js|css|swf)$ {
      valid_referers none blocked server_names *.abc.com;
      if ($invalid_referer) {
        return   403;
      }
      expires 1d;
      add_header  X-Cache   HIT;
      root         /static/abc;
    }


    location / {
      proxy_pass  http://127.0.0.1:81;
      proxy_redirect  off;
      proxy_set_header  isme    "huairen";
      proxy_set_header  Host    $host;
      proxy_set_header  X-Real-IP    $remote_addr;
    }

主目录和静态文件可以相同可以不同,diy很强。还可以用try_files的方式
静态在上面,动态在下面。推荐用X-Real-IP,否则ip就有被人为伪造的可能
X-Cache是我的习惯,你可以忽略。删掉可以减少几字节,哈哈
我没用fastcgi,你相应的改下就行
(以上部分配置是从我的一个站点中截取出来的,基于nginx+perl。因内核改了很多,所以不可能全发出来,见谅)

btw:you should learn more foreign languages. for better use of nginx, i
even had self-russian

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,1888,1945#msg-1945
Igor S. (Guest)
on 2009-05-13 05:33
(Received via mailing list)
On Tue, May 12, 2009 at 03:56:32AM -0400, ?????? wrote:

> btw:you should learn more foreign languages. for better use of nginx, i even had 
self-russian

Learing foreign languages is certainyl good thing.
However, if you believe that anyone may translate your responses via
translate.google.com, you made mistake: its translation quality is poor.
Chris Cortese (Guest)
on 2009-05-15 02:05
(Received via mailing list)
Hi,

Problem is I'm only having the problem on Windows--where I'm using the
prebuilt Windows binary.

Is there any way to get a current Windows binary that is built with
debug on?

Thanks,
Chris
Igor S. (Guest)
on 2009-05-15 09:25
(Received via mailing list)
On Thu, May 14, 2009 at 02:58:44PM -0700, Chris Cortese wrote:

> Hi,
>
> Problem is I'm only having the problem on Windows--where I'm using the
> prebuilt Windows binary.
>
> Is there any way to get a current Windows binary that is built with
> debug on?

Sorry, I've missed that we talking about nginx/Windows.
It's already built --with-debug.
This topic is locked and can not be replied to.