feat/nginx-rtmp-move (#33)

* feat: initial and probably final rtmp server backend

* feat: video player and next-ws

* chore: cleanup livekit api routes

* feat: chat

* feat: move to nginx flv

* feat: no viewer streaminfo implementation
This commit is contained in:
2025-03-15 16:58:14 +01:00
committed by GitHub
parent 8d33c7eb62
commit 9837cbb713
30 changed files with 1110 additions and 406 deletions

View File

@@ -8,4 +8,39 @@ services:
volumes:
- ./psql:/var/lib/postgresql/data
ports:
- 5555:5432
- 5555:5432
nginx-rtmp:
# ports:
# - 1935:1935
# - 8888:8888
network_mode: host
environment:
UID: 1000
GID: 1000
API_AUTH: skibiditoilet
volumes:
- ./nginx.conf:/etc/nginx/templates/nginx.conf.template
- ./html:/var/www/html
- /dev/shm/hls:/dev/shm/hls
image: flv-module
entrypoint:
- /bin/sh
- -c
- |
# Process the template file
mkdir -p /usr/local/nginx/conf
envsubst '$${API_AUTH}' < /etc/nginx/templates/nginx.conf.template > /usr/local/nginx/conf/nginx.conf
echo "Setting UID to $${UID} and GID to $${GID}"
usermod -u $${UID} nginx || echo "failed to change uid"
groupmod -g $${GID} nginx || echo "failed to change gid"
mkdir -p /usr/local/nginx/proxy_temp /usr/local/nginx/client_body_temp
chown -R nginx:nginx /usr/local/nginx
mkdir -p /var/www/html
chown -R nginx:nginx /var/www/html
echo "testing nginx config..."
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx -g 'daemon off;'

0
dev/html/.gitkeep Normal file
View File

74
dev/nginx.conf Normal file
View File

@@ -0,0 +1,74 @@
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935;
application live {
live on;
record off;
on_publish http://localhost:3000/api/rtmp/publish;
}
application channel-live {
live on;
record off;
allow publish 127.0.0.1;
deny publish all;
hls on;
hls_type live;
hls_path /dev/shm/hls;
hls_fragment 2s;
hls_playlist_length 10s;
hls_cleanup on;
hls_variant _low BANDWIDTH=500000;
hls_variant _mid BANDWIDTH=1000000;
hls_variant _hi BANDWIDTH=1500000;
}
}
}
http {
include mime.types;
default_type application/octet-stream;
# performance optimizations
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
map $http_authorization $is_authorized {
default 0;
$API_AUTH 1;
}
server {
listen 8888;
location /stat {
if ($is_authorized = 0) {
return 401 "Unauthorized";
}
rtmp_stat all;
rtmp_stat_format json;
}
location /hls {
alias /dev/shm/hls;
add_header Cache-Control no-cache;
add_header Access-Control-Allow-Origin *;
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
}
}
}