Skip to content

Instantly share code, notes, and snippets.

@mksvdmtr
Forked from un33k/nginx.conf
Created June 26, 2019 12:24
Show Gist options
  • Save mksvdmtr/f16addd71addd93d6cbdcccf1fb55877 to your computer and use it in GitHub Desktop.
Save mksvdmtr/f16addd71addd93d6cbdcccf1fb55877 to your computer and use it in GitHub Desktop.
Enable Nginx to send Content-Dispositions on specific files
server {
listen *:80;
server_name www.example.com;
rewrite ^(.*) http://example.com $1 permanent;
}
server {
listen *:80;
server_name example.com;
# Static directory
location /data/ {
autoindex on;
alias /data/;
expires 30d;
if ($request_filename ~ "^.*/(.+\.zip|tgz|iso|gz)$"){
set $fname $1;
add_header Content-Disposition 'attachment; filename="$fname"';
}
}
root /srv/www/example.com;
access_log /srv/www/example.com/logs/access.log;
error_log /srv/www/example.com/logs/errors.log;
# Redirect server error pages to the static page /50x.html
error_page 500 502 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment