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.
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 on192.168.0.107
, then it’s expected you’d get an ERR_CONNECTION_REFUSED error forhttp://192.168.0.107/dash/test.mpd
. – sideshowbarkerroot usr/local/nginx/stream/dash
anddash_path usr/local/nginx/stream/dash
. I’d guess those should instead rightly beroot /usr/local/nginx/stream/dash
anddash_path /usr/local/nginx/stream/dash
. – sideshowbarker