nginx - NGINX open() 失败(20:不是目录)带有安全链接模块的 hls vod
问题描述
我对 hls 流的 nginx 配置有问题。我使用kaltura nginx vod 模块并尝试添加ngx_http_secure_link_module
以保护流。奇怪的是,如果我启用ngx_http_secure_link_module
(下面的日志),我会遇到 404 错误。我认为那是因为它最后找不到带有 index.m3u8 的文件,但是如果我评论安全链接块,它就可以正常工作。
我也尝试在location ~ \.m3u8$ {}
块内添加别名,但它没有用。我究竟做错了什么?如何保护我的流?
我的直播链接:https://stream.example.com/hls/c14de868-3130-426a-a0cc-7ff6590e9a1f/index.m3u8?md5=0eNJ3SpBd87NGFF6Hw_zMQ&expires=1609448340
我的 NGINX 配置:
server {
listen 9000;
server_name localhost;
# root /srv/static;
location ^~ /hls/ {
# the path to c14de868-3130-426a-a0cc-7ff6590e9a1f file
alias /srv/static/videos/1/;
# file with cors settings
include cors.conf;
vod hls;
# 1. Set secret variable
set $secret "s3cr3t";
# 2. Set secure link
secure_link $arg_md5,$arg_expires;
secure_link_md5 "$secure_link_expires $secret";
# if I comment this block everything works fine (but security)
location ~ \.m3u8$ {
if ($secure_link = "") { return 403; }
if ($secure_link = "0") { return 403; }
}
}
}
NGINX 日志:
解决方案
刚刚将此块移出到服务器目录并添加vod hls;
到里面。
location ~ \.m3u8$ {
include cors.conf;
vod hls;
if ($secure_link = "") { return 403; }
if ($secure_link = "0") { return 403; }
}
推荐阅读
- .htaccess - 使用 .htaccess 或 nginx 配置重写图像规则
- c# - C# - 调用另一个脚本失败
- inline-assembly - 如何将标签的地址加载到powerpc中的寄存器中
- express - 如何使用 Nginx 配置 Express
- c# - WPF 边框渲染
- python - TypeError: calculations() missing 1 required positional argument: 'entries'
- algorithm - 如何在 Redis 中实现队列管理系统
- sql-server - 在 SQL 中使用 CURSOR 从其他表获取值时更新一个表的记录
- google-cloud-storage - 删除文件夹时,无法使用版本控制在 GCS 中恢复文件
- c++11 - 为什么外部库在cmake中添加编译器标志-std=gnuc++11