简体   繁体   English

在跨来源请求中找不到Nginx 404上的Dash实时流

[英]Dash Live Streaming on Nginx 404 Not Found on Cross Origin Request

I want to set up a Dash Live Streaming nginx server to stream to a node.js app. 我想设置一个Dash Live Streaming Nginx服务器以流式传输到node.js应用程序。 I am new to nginx so tried finding the solution a lot, but no luck. 我是nginx的新手,所以尝试了很多解决方案,但是没有运气。 I have all the required modules installed and I want to display the dash stream via Shaka Player. 我已经安装了所有必需的模块,并且我想通过Shaka Player显示破折号流。

My nginx server is running on port 8080 and my node.js app is running on port 3000. I configured the server such that anyone on the Local Area Network can stream to this server via OBS. 我的nginx服务器在端口8080上运行,而我的node.js应用程序在端口3000上运行。我对服务器进行了配置,以使局域网上的任何人都可以通过OBS流到该服务器。 It is getting and storing the stream files properly. 它正在正确获取和存储流文件。 But every time my node app requests for the .mpd via shaka player, it displays: 但是,每当我的节点应用通过shaka播放器请求.mpd时,都会显示:

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

net::ERR_CONNECTION_REFUSED 网:: ERR_CONNECTION_REFUSED

The Shaka Player script displays error 1002, which I found to be related to CORS. Shaka Player脚本显示错误1002,我发现该错误与CORS有关。 I tried so so many ways to Allow Cross Origin Request but none worked. 我尝试了多种方法来允许跨源请求,但没有一种有效。 Here is my current nginx.config file: 这是我当前的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;
        }
    }
}

My current nginx version is 1.15.7. 我当前的nginx版本是1.15.7。 I tested both on windows and Ubuntu 17.10, with other versions too. 我在Windows和Ubuntu 17.10以及其他版本上都进行了测试。 I was unable to fix the problem. 我无法解决问题。

I also want to know whether add_header arguments need to be within quotes or not because I saw both versions on different places. 我还想知道add_header参数是否需要用引号引起来,因为我在不同的地方看到了两个版本。

Update: 更新:

Changed request url to http://192.168.0.107:8080/dash/test/index.mpd and http://192.168.0.107:8080/dash/test.mpd , changed nginx.conf /dash root to usr/local/nginx/stream/dash and usr/local/nginx/stream but none worked. 将请求URL更改为http://192.168.0.107:8080/dash/test/index.mpdhttp://192.168.0.107:8080/dash/test.mpd ,将nginx.conf / dash根更改为usr / local / nginx / stream / dash和usr / local / nginx / stream,但没有一个起作用。

Thanks a lot sideshowbarker for your help. 非常感谢sideshowbarker的帮助。 I changed the dash_path to /usr/local/nginx/stream/dash and root location to /usr/local/nginx/stream and it works fine. 我将dash_path更改为/ usr / local / nginx / stream / dash,将根目录更改为/ usr / local / nginx / stream,它可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM