Created
August 27, 2020 09:57
-
-
Save MParvin/7b6ed3219eee3438c3d801ef0231af5b to your computer and use it in GitHub Desktop.
Nginx config for rtmp and hls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
daemon off; | |
error_log logs/error.log; | |
events { | |
worker_connections 1024; | |
} | |
rtmp { | |
server { | |
listen 1935; # Listen on standard RTMP port | |
chunk_size 4000; | |
application show { | |
live on; | |
# Turn on HLS | |
hls on; | |
hls_path /opt/data/hls; | |
#hls_fragment 5; | |
#hls_playlist_length 10; | |
# disable consuming the stream from nginx as rtmp | |
#deny play all; | |
} | |
} | |
} | |
http { | |
sendfile off; | |
tcp_nopush on; | |
#aio on; | |
directio 512; | |
default_type application/octet-stream; | |
server { | |
listen 80; | |
location / { | |
# 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; | |
} | |
root /opt/data; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment