Posted By

vasilije on 12/22/08


Tagged

conf nginx


Versions (?)

Nginx force download for non image static files


 / Published in: Other
 

  1. server{
  2. listen 80;
  3. server_name test.localhost;
  4. location / {
  5. root /Users/vasil/test;
  6. if ($request_filename !~* ^.*?\.(jpg)|(png)|(gif)){
  7. add_header Content-Disposition: "$request_filename";
  8. }
  9. }
  10. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: b3ez on February 1, 2010

Works with Safari: location / { root /home/static;

            if ($request_filename !~* ^.*\/(.*?)\.(jpg)|(png)|(gif)){
                    add_header Content-Type "application/octet-stream";
                    add_header Content-Disposition "attachment; filename=$1";
            }
    }

You need to login to post a comment.