Nginx 404上的短暂直播流在跨源请求中找不到

问题描述 投票:0回答:1

我想设置一个Dash Live Streaming nginx服务器来流式传输到node.js应用程序。我是nginx的新手,所以试图找到解决方案很多,但没有运气。我安装了所有必需的模块,我想通过Shaka Player显示短划线流。

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

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

网:: 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和Ubuntu 17.10上测试了它们,还有其他版本。我无法解决问题。

我还想知道add_header参数是否需要在引号内,因为我在不同的地方看到了两个版本。

更新:

将请求URL更改为http://192.168.0.107:8080/dash/test/index.mpdhttp://192.168.0.107:8080/dash/test.mpd,将nginx.conf / dash root更改为usr / local / nginx / stream / dash和usr / local / nginx / stream但没有工作。

nginx http-status-code-404 live-streaming mpeg-dash nginx-config
1个回答
0
投票

非常感谢sideshowbarker的帮助。我将dash_path更改为/ usr / local / nginx / stream / dash和root位置到/ usr / local / nginx / stream,它运行正常。

© www.soinside.com 2019 - 2024. All rights reserved.