Nginx 404上的Dash实时流媒体在跨源请求中未找到



我想设置一个Dash Live Streaming nginx服务器,以流式传输到node.js应用程序。我是nginx的新手,所以尝试了很多次找到解决方案,但没有成功。我已经安装了所有需要的模块,我想通过Shaka Player显示dash流。

我的nginx服务器在8080端口上运行,node.js应用程序在3000端口上运行。我配置了服务器,使局域网上的任何人都可以通过OBS流到此服务器。它正在正确地获取和存储流文件。但每次我的节点应用程序通过shaka播放器请求.mpd时,它都会显示:

获取http://192.168.0.107/dash/test.mpd

net::ERR_CONNECTION_REFUSED

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和Ubuntu17.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/ningx/stream,但均无效。

非常感谢sideshowbarker的帮助。我将dash_path更改为/usr/local/nginx/stream/dash,将根位置更改为/usr/local/nginx/stream,一切正常。

最新更新