【发布时间】:2021-08-05 20:05:49
【问题描述】:
这是我的问题。我已将此代码添加到我的 nginx.conf 中:
location ~/.mp4 {
if ($args_dl = "1") {
types { application/octet-stream (.mp4); }
default_type application/octet-stream;
}
}
当我重新启动 nginx 时它说我
nginx: [emerg] "types" 指令在 /etc/nginx/nginx.conf:26 中是不允许的
为什么?第 26 行是types { application/octet-stream (.mp4); }
谢谢
编辑:真正的问题是:为什么如果我添加到代码if ($args_dl = "1") { nginx 说我“类型”的错误?我不明白它是如何工作的
RIEDIT:我认为这是因为我在 if 中输入了类型,但它不适合。如果没有 if,我怎么能做同样的事情?
RIRIEDIT:
我试过这个:
location ~* ^/.+\.(?:gif|jpe?g|png|mp4)$ {
autoindex off;
if ($arg_dl = "1") {
rewrite ^(.*)$ /download$1 last;
}
}
location ~ /download/.+\.(mp4) {
internal;
alias /home/$1;
types {}
expires -1;
default_type application/octet-stream;
}
它不起作用,因为我不知道如何设置别名以动态获取视频的 url 并使用我拥有的所有不同视频,当我更改 url 时浏览器给我 500 内部服务器错误位置链接
【问题讨论】:
标签: nginx