Created
May 3, 2016 22:56
-
-
Save douglasmiranda/be4faca729b9ed78f0ee815dda7ef70b to your computer and use it in GitHub Desktop.
Nginx: Make (PDF) file downloadable when accessed with parameter '?download=1'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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