You just need to return HTTP header Content-disposition:
location ~* /orig/(.+\.jpg)$ {
internal;
add_header Content-disposition "attachment; filename=$1";
}
Or
location ~* (.*\.pdf) {
types { application/octet-stream .pdf; }
default_type application/octet-stream;
}
Or full
server{
listen 80;
server_name test.localhost;
location / {
root /Users/vasil/test;
if ($request_filename !~* ^.*?\.(jpg)|(png)|(gif)){
add_header Content-Disposition: "$request_filename";
}
}
}