主题
文件下载模板
适合公开下载目录、安装包、压缩包、静态附件。
替换:
example.com/var/www/downloads
nginx
server {
listen 80;
listen [::]:80;
server_name example.com;
root /var/www/downloads;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
autoindex off;
sendfile on;
location / {
try_files $uri =404;
add_header Cache-Control "public, max-age=604800";
}
location ~* \.(?:zip|tar|gz|tgz|7z|dmg|exe|apk|ipa)$ {
try_files $uri =404;
add_header Cache-Control "public, max-age=604800";
add_header Content-Disposition "attachment";
}
}