我试图根据文件的扩展名重写请求 uri,然后仅从 uri 中提取文件名并将其存储在另一个文件夹中。这里的问题是文件名和可用变量没有预定义的变量uri
,request_uri
并且request_filename
会给出完整的 uri。
server{
set $file_folder D:/nginx-1.0.15/imageAll/;
location ~*+.(gif|jpg)$ {
try_files $uri @imgstore;
}
location @imgstore {
proxy_pass $file_folder$request_filename;
proxy_store on;
proxy_temp_path /nginx-1.0.15/images/;
proxy_store_access user:rw group:rw all:r;
}
}
Run Code Online (Sandbox Code Playgroud)
我能做的最好的事情就是获得扩展名 .jpg 或 .gif,当我把$1
它放在$request_filename
这样的地方时:
location @imgstore {
proxy_pass $file_folder$1;
}
Run Code Online (Sandbox Code Playgroud)
所以,我想知道: