server {
.....
location ~* .*\.(doc|txt|jar|zip|apk)(\?.*)?$ {
if ($request_uri ~* ^.*\/(.*)\.(doc|txt|jar|zip|apk)(\?name=([^&]+))$) {
add_header Content-Disposition "attachment;filename=$arg_name.$2";
}
}