Update Setting up an HLS Broadcast server with NGINX

rainbow napkin 2025-03-19 02:25:46 +00:00
parent 43b2987bcb
commit 589a538c82

@ -26,7 +26,12 @@ The first part of this server config handles ingesting the raw RTMP datastream a
hls_nested on; hls_nested on;
hls_path /srv/live; hls_path /srv/live;
hls_fragment 2s; #This changes how nginx splits the streams into files
#Increasing fragment length will increase delay
#Make sure your keyframe interval in OBS matches this number!
#Split Stream into 2 second fragments
hls_fragment 2s;
#Provide 10 seconds worth of fragments (5 fragments)
hls_playlist_length 10s; hls_playlist_length 10s;
} }
} }
@ -37,3 +42,25 @@ This part of the configuration handles setting up the web server which serves th
1. Edit `/etc/nginx/sites-available/default` or create a new site config 1. Edit `/etc/nginx/sites-available/default` or create a new site config
<br><sup>Remember to create a symlink and move/delete the default if you create a new file!</sup> <br><sup>Remember to create a symlink and move/delete the default if you create a new file!</sup>
2. Add the following to your site config: 2. Add the following to your site config:
<pre><code>server {
listen 80;
listen [::]:80 ipv6only=on;
root /srv/live;
server_name your.domain.name;
location / {
#You'll probably want to use this from another site :P
add_header Access-Control-Allow-Origin https://domain.to.allow;
add_header Cache-Control no-cache;
#Default to playlist file to allow users to just paste the bare domain
try_files $uri $uri/index.m3u8;
types{
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
}
}</pre></code>