Skip to content

Commit 92401bd

Browse files
jss-tgipcjs
andauthored
fix: 通过nginx给minio添加下载头 (#42)
Co-authored-by: ipcjs.mac4 <[email protected]>
1 parent 6288765 commit 92401bd

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

nginx/conf/conf.d/track.conf.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ server {
6161

6262
location /minio/ {
6363
proxy_pass http://${MINIO_HOST}:${MINIO_PORT}/;
64+
65+
add_header Content-Disposition $content_disposition_download;
6466
}
6567

6668
location /jtt808/ {

nginx/conf/conf.d/video-minio.conf.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ server {
1616
# minio录像云存储
1717
location /minio/ {
1818
proxy_pass http://${MINIO_HOST}:${MINIO_PORT}/;
19+
20+
add_header Content-Disposition $content_disposition_download;
1921
}
2022

2123
#access_log /var/log/nginx/host.access.log main;

nginx/conf/nginx.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ http {
7575
~*(GPTBot|ChatGPT-User|ClaudeBot|PerplexityBot|CCBot) 1;
7676
}
7777

78+
# 前端设置<a>标签的download属性, 只对同源url生效, minio默认不会设置Content-Disposition响应头
79+
# 故需要通过nginx解析url中的download=1参数, 添加响应头
80+
# 参考: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#download
81+
map $arg_download $content_disposition_download {
82+
default "";
83+
"1" "attachment";
84+
}
85+
7886
# Docker Compose的默认DNS
7987
# https://stackoverflow.com/questions/35744650/docker-network-nginx-resolver
8088
resolver 127.0.0.11;

0 commit comments

Comments
 (0)