http { # include mime.types; default_type application/octet-stream; types { text/plain txt; text/html html; text/css css; application/javascript js; application/vnd.apple.mpegurl m3u8; video/mp2t ts; application/rss+xml xml; } server { listen 1936; listen [::]:1936 ipv6only=on; set $cors ''; if ($http_origin ~ '^https?\:\/\/(localhost(\:[\d+])?|\d+\.\d+\.\d+.\d+|(www\.)?ispooge\.com|(www\.)?harlanji\.com|(www\.)?tinydatacenter\.com)\/?') { set $cors 'C'; } set $cors_opts ''; if ($request_method = 'OPTIONS') { set $cors_opts "${cors}O"; } location /hls/ { rewrite ^/hls/(.*) /$1 break; if ($cors = 'C') { add_header 'Access-Control-Allow-Origin' "$http_origin" always; add_header 'Access-Control-Allow-Credentials' 'true' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always; # required to be able to read Authorization header in frontend #add_header 'Access-Control-Expose-Headers' 'Authorization' always; } if ($cors_opts = 'CO') { add_header 'Access-Control-Max-Age' 60; add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Length' 0; return 204; } root /tmp/http/hls/ispooge.com/; } # This URL provides RTMP statistics in XML location /hls/stat { rtmp_stat all; # Use this stylesheet to view XML as web page # in browser rtmp_stat_stylesheet stat.xsl; } location /media/ { rewrite ^/media/(.*) /$1 break; root /tmp/http/media/; } location / { if ($cors = 'C') { add_header 'Access-Control-Allow-Origin' "$http_origin" always; add_header 'Access-Control-Allow-Credentials' 'true' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always; # required to be able to read Authorization header in frontend #add_header 'Access-Control-Expose-Headers' 'Authorization' always; } if ($cors_opts = 'CO') { add_header 'Access-Control-Max-Age' 60; add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Length' 0; return 204; } root /tmp/http/cryogen/; } } } worker_processes auto; rtmp_auto_push on; events {} rtmp { server { listen 1935; listen [::]:1935 ipv6only=on; chunk_size 4096; application participant { live on; } # monitor rtmp application record { live on; record all; record_path /tmp/rec; record_suffix _%Y-%m-%d_%H-%M-%S.flv; record_lock on; } application hls { live on; hls on; hls_path /tmp/http/hls/ispooge.com; #hls_base_url http://192.168.1.8:33080/hls/; hls_fragment 500ms; hls_playlist_length 3s; hls_fragment_naming_granularity 500; hls_continuous on; hls_nested on; hls_cleanup off; hls_fragment_naming system; hls_fragment_slicing aligned; hls_type live; hls_variant _720 BANDWIDTH=6491456 RESOLUTIO=1280x720; hls_variant _360 BANDWIDTH=3345728 RESOLUTION=640x360; hls_variant _240 BANDWIDTH=1248576 RESOLUTION=416x240; } application ispoogedaily_local { live on; push rtmp://127.0.0.1 app=hls live=1; } application ispoogedaily_source { live on; } application ispoogedaily_live { live on; #play_restart on; drop_idle_publisher 15s; #publish_notify on; wait_key on; wait_video on; # interleave on; #meta copy; # YT LIVE #push rtmp://a.rtmp.youtube.com app=live2 playpath=YT_KEY live=1; # Twitch #push rtmp://live-sjc.twitch.tv app=app playpath=TWITCH_KEY live=1; } } }