【问题标题】:Dash Live Streaming on Nginx 404 Not Found on Cross Origin Request在跨域请求中未找到 Nginx 404 上的 Dash 实时流式传输
【发布时间】:2019-05-16 17:11:15
【问题描述】:

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

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

GET 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 和 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 但没有一个有效。

【问题讨论】:

  • 你试过http://192.168.0.107:8080/dash/test.mpd吗?也就是说,使用端口 8080 - 因为您说您在端口 8080 上设置了 nginx 服务器。如果您在 192.168.0.107 的端口 80 上没有运行任何服务器,那么预计您会收到 @987654327 的 ERR_CONNECTION_REFUSED 错误@.
  • 感谢 sideshowbarker 的快速回复。您的解决方案已解决 err_connection_refused。但现在我收到错误 404(未找到)。我在目录中做错了吗?
  • 仅根据当前问题中的信息,我认为这里没有人能告诉您为什么这些路线会收到 404。但我注意到的一件事是你的 nginx 配置有root usr/local/nginx/stream/dashdash_path usr/local/nginx/stream/dash。我猜这些应该是root /usr/local/nginx/stream/dashdash_path /usr/local/nginx/stream/dash

标签: nginx http-status-code-404 live-streaming mpeg-dash nginx-config


【解决方案1】:

非常感谢 sideshowbarker 的帮助。我将 dash_path 更改为 /usr/local/nginx/stream/dash 并将根位置更改为 /usr/local/nginx/stream 并且它工作正常。

【讨论】:

    猜你喜欢
    • 2015-12-01
    • 2013-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-01
    • 1970-01-01
    • 2013-03-11
    • 2013-12-03
    相关资源
    最近更新 更多