feat: XLive 直播平台初始版本
多用户网页直播平台:OBS/FFmpeg 鉴权 RTMP 推流到 SRS,HLS 低延迟播放; Fastify 5 + Prisma + PostgreSQL + Redis 后端,Vue 3 前端,Docker Compose 部署。
This commit is contained in:
1 parent
5ef949fe07
commit
463dbb1566
73 files changed
+9593
No files matched your search
@@ -0,0 +1,49 @@
|
||||
upstream xlive_api { server api:3000; keepalive 32; }
|
||||
upstream xlive_web { server web:80; keepalive 16; }
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
location /api/media/hooks { return 404; }
|
||||
location /api/ {
|
||||
proxy_pass http://xlive_api;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Request-ID $request_id;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
}
|
||||
location = /health { proxy_pass http://xlive_api/health; proxy_set_header X-Request-ID $request_id; }
|
||||
location ~ ^/live/.*\.flv$ {
|
||||
proxy_pass http://srs:8080;
|
||||
proxy_http_version 1.1;
|
||||
proxy_buffering off;
|
||||
proxy_cache off;
|
||||
proxy_read_timeout 300s;
|
||||
add_header Cache-Control "no-cache, no-store" always;
|
||||
add_header Access-Control-Allow-Origin "*" always;
|
||||
}
|
||||
location ~ ^/transcode/live/.*\.flv$ {
|
||||
rewrite ^/transcode/live/(.*)$ /live/$1 break;
|
||||
proxy_pass http://srs2:8081;
|
||||
proxy_http_version 1.1;
|
||||
proxy_buffering off;
|
||||
proxy_cache off;
|
||||
proxy_read_timeout 300s;
|
||||
add_header Cache-Control "no-cache, no-store" always;
|
||||
add_header Access-Control-Allow-Origin "*" always;
|
||||
}
|
||||
location /live/ {
|
||||
alias /var/www/live/;
|
||||
add_header Access-Control-Allow-Origin "*" always;
|
||||
add_header Cache-Control "no-cache, no-store" always;
|
||||
types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; video/mp4 m4s mp4; }
|
||||
try_files $uri =404;
|
||||
}
|
||||
location /uploads/ { alias /var/www/uploads/; expires 7d; add_header X-Content-Type-Options nosniff; }
|
||||
location / { proxy_pass http://xlive_web; proxy_set_header Host $host; }
|
||||
}
|
||||
|
||||
# Production: obtain a certificate with certbot, then enable TLS here and redirect HTTP.
|
||||
@@ -0,0 +1,20 @@
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
events { worker_connections 2048; }
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
log_format main '$remote_addr - $request_id [$time_local] "$request" $status $body_bytes_sent';
|
||||
access_log /var/log/nginx/access.log main;
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
keepalive_timeout 65;
|
||||
client_max_body_size 10m;
|
||||
server_tokens off;
|
||||
gzip on;
|
||||
gzip_types text/plain text/css application/json application/javascript application/vnd.apple.mpegurl;
|
||||
map $http_upgrade $connection_upgrade { default upgrade; '' close; }
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
daemon off;
|
||||
srs_log_tank console;
|
||||
|
||||
http_api {
|
||||
enabled on;
|
||||
listen 1985;
|
||||
}
|
||||
|
||||
http_server {
|
||||
enabled on;
|
||||
listen 8080;
|
||||
dir ./objs/nginx/html;
|
||||
}
|
||||
|
||||
vhost __defaultVhost__ {
|
||||
tcp_nodelay on;
|
||||
min_latency on;
|
||||
play {
|
||||
gop_cache off;
|
||||
queue_length 10;
|
||||
mw_latency 100;
|
||||
}
|
||||
publish {
|
||||
mr off;
|
||||
}
|
||||
hls {
|
||||
enabled on;
|
||||
hls_path ./objs/nginx/html;
|
||||
hls_fragment 1;
|
||||
hls_window 6;
|
||||
hls_cleanup on;
|
||||
hls_dispose 30;
|
||||
hls_m3u8_file live/[stream].m3u8;
|
||||
hls_ts_file live/[stream]-[seq].ts;
|
||||
}
|
||||
dvr {
|
||||
enabled on;
|
||||
dvr_path ./objs/nginx/html/[app]/replays/[stream].[timestamp].flv;
|
||||
dvr_plan session;
|
||||
}
|
||||
http_remux {
|
||||
enabled on;
|
||||
mount [vhost]/[app]/[stream].flv;
|
||||
}
|
||||
http_hooks {
|
||||
enabled on;
|
||||
on_publish http://api:3000/api/media/hooks?secret=__HOOK_SECRET__;
|
||||
on_unpublish http://api:3000/api/media/hooks?secret=__HOOK_SECRET__;
|
||||
on_dvr http://api:3000/api/media/hooks?secret=__HOOK_SECRET__;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
listen 1936;
|
||||
max_connections 1000;
|
||||
daemon off;
|
||||
srs_log_tank console;
|
||||
|
||||
http_server {
|
||||
enabled on;
|
||||
listen 8081;
|
||||
dir ./objs/nginx/html;
|
||||
}
|
||||
|
||||
vhost __defaultVhost__ {
|
||||
tcp_nodelay on;
|
||||
min_latency on;
|
||||
play {
|
||||
gop_cache off;
|
||||
queue_length 10;
|
||||
mw_latency 100;
|
||||
}
|
||||
publish {
|
||||
mr off;
|
||||
}
|
||||
hls {
|
||||
enabled on;
|
||||
hls_path ./objs/nginx/html;
|
||||
hls_fragment 1;
|
||||
hls_window 6;
|
||||
hls_cleanup on;
|
||||
hls_dispose 30;
|
||||
hls_m3u8_file live/[stream].m3u8;
|
||||
hls_ts_file live/[stream]-[seq].ts;
|
||||
}
|
||||
http_remux {
|
||||
enabled on;
|
||||
mount [vhost]/[app]/[stream].flv;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user