location ^~/temp{ alias /home/file/temp; expires 7d; if ($request_uri ~* ^.*\/(.*)\.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx|jpg|png)(\?n=([^&]+))$) { add_header Content-Disposition "attachment;filename=$arg_n.$2"; } }