From 589a538c82c35c1ee78d46d3b92c3e4a64f7e778 Mon Sep 17 00:00:00 2001 From: rainbow napkin Date: Wed, 19 Mar 2025 02:25:46 +0000 Subject: [PATCH] Update Setting up an HLS Broadcast server with NGINX --- ...g-up-an-HLS-Broadcast-server-with-NGINX.md | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Setting-up-an-HLS-Broadcast-server-with-NGINX.md b/Setting-up-an-HLS-Broadcast-server-with-NGINX.md index f522a83..a283291 100644 --- a/Setting-up-an-HLS-Broadcast-server-with-NGINX.md +++ b/Setting-up-an-HLS-Broadcast-server-with-NGINX.md @@ -26,7 +26,12 @@ The first part of this server config handles ingesting the raw RTMP datastream a hls_nested on; 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; } } @@ -36,4 +41,26 @@ The first part of this server config handles ingesting the raw RTMP datastream a This part of the configuration handles setting up the web server which serves the files that make up the HLS stream. 1. Edit `/etc/nginx/sites-available/default` or create a new site config
Remember to create a symlink and move/delete the default if you create a new file! -2. Add the following to your site config: \ No newline at end of file +2. Add the following to your site config: +
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;
+		}
+	}
+}
\ No newline at end of file