简体   繁体   中英

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. I am new to nginx so tried finding the solution a lot, but no luck. I have all the required modules installed and I want to display the dash stream via 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. It is getting and storing the stream files properly. But every time my node app requests for the .mpd via shaka player, it displays:

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

net::ERR_CONNECTION_REFUSED

The Shaka Player script displays error 1002, which I found to be related to CORS. I tried so so many ways to Allow Cross Origin Request but none worked. Here is my current nginx.config file:

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. I tested both on windows and Ubuntu 17.10, with other versions too. 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.

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.

Thanks a lot sideshowbarker for your help. I changed the dash_path to /usr/local/nginx/stream/dash and root location to /usr/local/nginx/stream and it works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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