多用户网页直播平台:OBS/FFmpeg 鉴权 RTMP 推流到 SRS,HLS 低延迟播放; Fastify 5 + Prisma + PostgreSQL + Redis 后端,Vue 3 前端,Docker Compose 部署。
50 lines
1.8 KiB
Plaintext
50 lines
1.8 KiB
Plaintext
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.
|