Skip to content

Instantly share code, notes, and snippets.

@douglasmiranda
Created May 3, 2016 22:56
Show Gist options
  • Save douglasmiranda/be4faca729b9ed78f0ee815dda7ef70b to your computer and use it in GitHub Desktop.
Save douglasmiranda/be4faca729b9ed78f0ee815dda7ef70b to your computer and use it in GitHub Desktop.
Nginx: Make (PDF) file downloadable when accessed with parameter '?download=1'
# http://mysite.com/media/file.pdf
# absolute path: /path/to/media/directory/file.pdf
location /media {
alias /path/to/media/directory;
expires max;
access_log off;
location ~* \.(pdf)$ {
if ($arg_download = 1){
add_header Content-Disposition 'attachment;';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment