Skip to content

Instantly share code, notes, and snippets.

@shivasiddharth
Created June 21, 2020 13:39
Show Gist options
  • Save shivasiddharth/30b998189c3dc76fdea4227f29e9dcf7 to your computer and use it in GitHub Desktop.
Save shivasiddharth/30b998189c3dc76fdea4227f29e9dcf7 to your computer and use it in GitHub Desktop.
Sample Nginx conf file for Dash streaming
worker_processes auto;
events {
worker_connections 1024;
}
# RTMP configuration
rtmp {
server {
listen 1935;
chunk_size 4000;
application show {
live on;
interleave on;
dash on;
dash_path /mnt/dash/;
dash_fragment 15s;
}
}
}
http {
sendfile off;
tcp_nopush on;
directio 512;
default_type application/octet-stream;
server {
listen 8080;
location /dash {
# Disable cache
add_header 'Cache-Control' 'no-cache';
# CORS setup
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length';
# allow CORS preflight requests
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
types {
application/dash+xml mpd;
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
text/html html;
}
root /mnt/;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment