找到^~后的Nginx测试另一个位置

找到^~后的Nginx测试另一个位置,nginx,sendfile,Nginx,Sendfile,我在nginx1.4.4上使用sendfile,在windows7上使用php5.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_fil

我在nginx1.4.4上使用sendfile,在windows7上使用php5.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\u文件夹前缀。为什么将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

它不应该是带有斜杠而不是反斜杠的
X-Accel-Redirect:/upload_folder/Z5lvSRzMLxjNZZx6xJb70GiCTNKM8ZqP.jpg
。应该是/不是\。我使用的是目录分隔符,而不是/所以在linux上可以,但在windows上不行。谢谢阿列克谢腾