Audio nginx:如何避免在所有wav文件中强制下载?
这是我的nginx站点配置文件:Audio nginx:如何避免在所有wav文件中强制下载?,audio,nginx,mime-types,Audio,Nginx,Mime Types,这是我的nginx站点配置文件: server { listen 81; root /path/; index index.php index.html index.htm; location ~* ^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ { access_log off; expires 30d
server {
listen 81;
root /path/;
index index.php index.html index.htm;
location ~* ^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ {
access_log off;
expires 30d;
}
location /path/to/sounds {
add_header Content-Disposition "inline";
}
location / {
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
include fastcgi_params;
}
}
我在一个特定的文件夹中有几个wav文件:0001.wav,0002.wav,a.wav,b.wav
页面应该播放这些文件,但在某些情况下(以字母开头的文件,如A.wav、b.wav),Chrome正在下载这些文件。这很奇怪
对于a.wav文件,Chrome控制台日志显示:
Resource interpreted as Document but transferred with MIME type application/octet-stream:
而相同的控制台日志显示:
Resource interpreted as Document but transferred with MIME type audio/x-wav
我在同一台服务器上安装了Apache。它适用于所有文件:
Resource interpreted as Document but transferred with MIME type audio/x-wav
我已经在/etc/nginx/mime.types中添加了:
audio/x-wav wav;
此外,我还替换了
location /path/to/sounds {
到
这里出了什么问题?已解决:
我在mime.types文件中添加了:
audio/x-wav wav;
在我的nginx配置中:
location ~ \.wav$ {
add_header Content-Disposition "inline";
}
location ~ \.wav$ {
add_header Content-Disposition "inline";
}