Last active
December 16, 2021 17:33
-
-
Save fschuindt/e1691faa591c406beb4c909fa00a02e2 to your computer and use it in GitHub Desktop.
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
load_module /usr/lib/nginx/modules/ngx_stream_module.so; | |
worker_processes auto; | |
error_log /home/broadcaster/log/error.log warn; | |
pid /home/broadcaster/run/nginx.pid; | |
events { | |
worker_connections 768; | |
} | |
# Ports and protocols. | |
# 4936 - RTMPS (Publish) | |
# 4935 - RTMP (Publish) | |
# 4090 - Authentication HTTP (both Watch and Publish) (Internal) | |
# 4080 - Broadcast HTTP (Watch) | |
# 4443 - Broadcast HTTPS (Watch) | |
# RTMPS | |
stream { | |
upstream rtmp_backend { | |
server 127.0.0.1:4935; | |
} | |
server { | |
listen 4936 ssl; | |
proxy_pass rtmp_backend; | |
ssl_certificate /home/broadcaster/ssl/cert.pem; | |
ssl_certificate_key /home/broadcaster/ssl/key.pem; | |
} | |
} | |
# RTMP | |
rtmp { | |
server { | |
listen 4935; | |
notify_method get; | |
application live { | |
live on; | |
record off; | |
interleave on; | |
on_publish http://127.0.0.1:4090/auth_publish; | |
on_play http://127.0.0.1:4090/auth_play; | |
# HLS | |
hls on; | |
hls_path /home/broadcaster/stream_data/hls; | |
hls_fragment 15s; | |
# DASH | |
dash on; | |
dash_path /home/broadcaster/stream_data/dash; | |
dash_fragment 15s; | |
} | |
} | |
} | |
# Authentication and Broadcast | |
http { | |
default_type application/octet-stream; | |
# Authentication HTTP (Internal) | |
server { | |
listen 4090; | |
allow 127.0.0.1; | |
deny all; | |
location /auth_publish { | |
if ($arg_streamkey = '5f3e32f3bad0') { | |
return 204; | |
} | |
return 404; | |
} | |
location /auth_play { | |
if ($arg_watchkey = '16356b9f') { | |
return 204; | |
} | |
return 404; | |
} | |
} | |
# Broadcast HTTPS | |
server { | |
listen 4443 ssl; | |
ssl_certificate /home/broadcaster/ssl/cert.pem; | |
ssl_certificate_key /home/broadcaster/ssl/key.pem; | |
location / { | |
add_header Access-Control-Allow-Origin *; | |
root /home/broadcaster/stream_data; | |
} | |
} | |
# Broadcast HTTP | |
server { | |
listen 4080; | |
location / { | |
add_header Access-Control-Allow-Origin *; | |
root /home/broadcaster/stream_data; | |
} | |
} | |
# Broadcast HTTP/HTTPS Types | |
types { | |
# HLS | |
application/vnd.apple.mpegurl m3u8; | |
video/mp2t ts; | |
# DASH | |
text/html html; | |
application/dash+xml mpd; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment