0

我在 nginx 1.4.4 上使用 sendfile,在Windows 7上使用 php 5.5.8(来自 WT-NMP) 。我在配置中有这两个位置。

location ^~ /upload_folder/ {
    internal;
    alias "c:/WT-NMP/WWW/m24/upload/";
}

location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|woff|ttf|svg|otf|mp3)$ {
    try_files $uri =404;
}

当我将标题设置为

X-Accel-Redirect: \upload_folder\Z5lvSRzMLxjNZZx6xJb70GiCTNKM8ZqP.jpg

然后测试第一个位置,看起来它在我的磁盘上找到了正确的文件。但是随后对位置进行了另一次测试,现在第二个位置已匹配,但正如我在文档中阅读的那样,搜索位置应该停止,因为我在/upload_folder位置之前使用了^~前缀。为什么将 nginx 测试位置作为第二个位置?在 Linux 上,a 具有非常相似的配置,但它按预期工作。

我的日志中有一些最重要的行:

2014/03/27 14:14:04 [debug] 11116#12652: *766 test location: "/"
2014/03/27 14:14:04 [debug] 11116#12652: *766 test location: "upload_folder/"
2014/03/27 14:14:04 [debug] 11116#12652: *766 test location: ~ "/themes/\w+/views"
2014/03/27 14:14:04 [debug] 11116#12652: *766 test location: ~ "\.    (js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|woff|ttf|svg|otf|mp3)$"
2014/03/27 14:14:04 [debug] 11116#12652: *766 test location: ~ "\.php$"
2014/03/27 14:14:04 [debug] 11116#12652: *766 using configuration "\.php$"
.
.
2014/03/27 14:14:04 [debug] 11116#12652: *766 http fastcgi parser: 0
2014/03/27 14:14:04 [debug] 11116#12652: *766 http fastcgi header: "X-Powered-By: PHP/5.5.8"
2014/03/27 14:14:04 [debug] 11116#12652: *766 http fastcgi parser: 0
2014/03/27 14:14:04 [debug] 11116#12652: *766 http fastcgi header: "Expires: Thu, 19 Nov 1981 08:52:00 GMT"
2014/03/27 14:14:04 [debug] 11116#12652: *766 http fastcgi parser: 0
2014/03/27 14:14:04 [debug] 11116#12652: *766 http fastcgi header: "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
2014/03/27 14:14:04 [debug] 11116#12652: *766 http fastcgi parser: 0
2014/03/27 14:14:04 [debug] 11116#12652: *766 http fastcgi header: "Pragma: no-cache"
2014/03/27 14:14:04 [debug] 11116#12652: *766 http fastcgi parser: 0
2014/03/27 14:14:04 [debug] 11116#12652: *766 http fastcgi header: "Content-Type: image/jpeg"
2014/03/27 14:14:04 [debug] 11116#12652: *766 http fastcgi parser: 0
2014/03/27 14:14:04 [debug] 11116#12652: *766 http fastcgi header: "Content-Disposition: attachment; filename="testfile.jpg""
2014/03/27 14:14:04 [debug] 11116#12652: *766 http fastcgi parser: 0
2014/03/27 14:14:04 [debug] 11116#12652: *766 http fastcgi header: "X-Accel-Redirect: \upload_folder\Z5lvSRzMLxjNZZx6xJb70GiCTNKM8ZqP.jpg"
2014/03/27 14:14:04 [debug] 11116#12652: *766 http fastcgi parser: 0
.
.
2014/03/27 14:14:04 [debug] 11116#12652: *766 internal redirect: "\upload_folder\Z5lvSRzMLxjNZZx6xJb70GiCTNKM8ZqP.jpg?"
2014/03/27 14:14:04 [debug] 11116#12652: *766 rewrite phase: 1
2014/03/27 14:14:04 [debug] 11116#12652: *766 test location: "/"
2014/03/27 14:14:04 [debug] 11116#12652: *766 test location: ~ "/themes/\w+/views"
2014/03/27 14:14:04 [debug] 11116#12652: *766 test location: ~ "\.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|woff|ttf|svg|otf|mp3)$"
2014/03/27 14:14:04 [debug] 11116#12652: *766 using configuration "\.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|woff|ttf|svg|otf|mp3)$"
.
.
2014/03/27 14:14:04 [debug] 11116#12652: *766 try files phase: 11
2014/03/27 14:14:04 [debug] 11116#12652: *766 http script var: "\upload_folder\Z5lvSRzMLxjNZZx6xJb70GiCTNKM8ZqP.jpg"
2014/03/27 14:14:04 [debug] 11116#12652: *766 trying to use file: "\upload_folder\Z5lvSRzMLxjNZZx6xJb70GiCTNKM8ZqP.jpg" "c:/wt-nmp/www/m24/web\upload_folder\Z5lvSRzMLxjNZZx6xJb70GiCTNKM8ZqP.jpg"
2014/03/27 14:14:04 [debug] 11116#12652: *766 trying to use file: "=404" "c:/wt-nmp/www/m24/web=404"
2014/03/27 14:14:04 [debug] 11116#12652: *766 http finalize request: 404, "\upload_folder\Z5lvSRzMLxjNZZx6xJb70GiCTNKM8ZqP.jpg?" a:1, c:2
2014/03/27 14:14:04 [debug] 11116#12652: *766 http special response: 404, "\upload_folder\Z5lvSRzMLxjNZZx6xJb70GiCTNKM8ZqP.jpg?"
2014/03/27 14:14:04 [debug] 11116#12652: *766 HTTP/1.1 404 Not Found
4

0 回答 0