我想建立一个Dash直播流nginx服务器流到node.js应用程序。我是新来的nginx,所以尝试了很多解决方案,但没有运气。我已经安装了所有必需的模块,我想通过Shaka播放器显示仪表板流。
我的nginx服务器在端口8080上运行,node.js应用程序在端口3000上运行。我对服务器进行了配置,以便局域网上的任何人都可以通过OBS流到此服务器。它正在正确地获取和存储流文件。但每次我的节点应用程序通过shaka player请求.mpd时,它都会显示:
得到
http://192.168.0.107/dash/test.mpd
net::ERR_连接被拒绝
Shaka Player脚本显示错误1002,我发现它与CORS有关。我尝试了很多方法来允许跨源请求,但都没有成功。这是我当前的nginx.config文件:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
server {
listen 8080;
location / {
root html;
index index.html index.htm;
}
location /dash {
add_header Access-Control-Allow-Origin * always;
add_header Cache-Control no-cache always;
root usr/local/nginx/stream/dash;
}
}
}
rtmp {
server {
listen 1935;
chunk_size 4096;
application dash {
live on;
record off;
dash on;
dash_nested on;
dash_path usr/local/nginx/stream/dash;
dash_fragment 3;
dash_playlist_length 120;
dash_cleanup on;
}
}
}
我现在的nginx版本是1.15.7。我在windows和Ubuntu 17.10上进行了测试,还有其他版本。我无法解决这个问题。
我还想知道add_header参数是否需要在引号内,因为我在不同的地方看到了这两个版本。
更新:
已将请求url更改为
http://192.168.0.107:8080/dash/test/index.mpd
和
http://192.168.0.107:8080/dash/test.mpd
,将nginx.conf/dash root更改为usr/local/nginx/stream/dash和usr/local/nginx/stream,但都没有成功。