0
votes

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.

1
Have you tried http://192.168.0.107:8080/dash/test.mpd? That is, with port 8080 — because you said you set up the nginx server on port 8080. If you don’t have any server running on port 80 on 192.168.0.107, then it’s expected you’d get an ERR_CONNECTION_REFUSED error for http://192.168.0.107/dash/test.mpd.sideshowbarker
Thank you sideshowbarker for your quick reply. Your solution has solved err_connection_refused. But now I am getting Error 404 (Not Found). Have I done something wrong in the directories?HawKk
Just base on the information currently in the question, I don’t think anybody here can tell you why you’re getting 404s for those routes. But one thing I notice is that your nginx config has root usr/local/nginx/stream/dash and dash_path usr/local/nginx/stream/dash. I’d guess those should instead rightly be root /usr/local/nginx/stream/dash and dash_path /usr/local/nginx/stream/dash.sideshowbarker

1 Answers

0
votes

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.