I am trying to rewrite the request uri depending on the extension of the file, then extract only the file name from the uri and store it in another folder. The problem here is no predefined variable for file name and the available variables uri
, request_uri
and request_filename
will give the full 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;
}
}
the best I can do is getting the extension .jpg or .gif, that when I put $1
in place of $request_filename
like this:
location @imgstore {
proxy_pass $file_folder$1;
}
So, I want to know :
- How to get the file name from the request?
- Is it the right way to store images from folder to another?