refactor(nginx): nginx only handles rtmp connections
Not longer handles frontend & backend. Partially for ease of development and also for separation of concenrs.
This commit is contained in:
@@ -3,4 +3,3 @@ FROM tiangolo/nginx-rtmp
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
EXPOSE 1935
|
||||
EXPOSE 8080
|
||||
|
||||
@@ -3,6 +3,15 @@ events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
upstream backend {
|
||||
server 127.0.0.1:8080;
|
||||
}
|
||||
|
||||
upstream frontend {
|
||||
server 127.0.0.1:5173;
|
||||
}
|
||||
|
||||
|
||||
rtmp {
|
||||
server {
|
||||
listen 1935;
|
||||
@@ -23,61 +32,19 @@ rtmp {
|
||||
}
|
||||
}
|
||||
|
||||
# Serve the HLS segments over HTTP
|
||||
http {
|
||||
sendfile off;
|
||||
tcp_nopush on;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# Allow large uploads (matches Spring Boot multipart limit)
|
||||
client_max_body_size 2g;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen 8088;
|
||||
|
||||
# Spring Boot API
|
||||
location /api/v1/ {
|
||||
proxy_pass http://vod_backend:8080;
|
||||
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;
|
||||
|
||||
# Large upload timeouts
|
||||
proxy_read_timeout 600s;
|
||||
proxy_send_timeout 600s;
|
||||
proxy_request_buffering off;
|
||||
}
|
||||
|
||||
# HLS stream playback
|
||||
location /hls {
|
||||
types {
|
||||
application/vnd.apple.mpegurl m3u8;
|
||||
video/mp2t ts;
|
||||
application/vnd.apple.mpegurl m3u8; # proper MIME for HLS playlists
|
||||
video/mp2t ts; # MPEG-TS segment MIME
|
||||
}
|
||||
root /tmp;
|
||||
add_header Cache-Control no-cache;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
|
||||
# RTMP stats
|
||||
location /stat {
|
||||
rtmp_stat all;
|
||||
rtmp_stat_stylesheet stat.xsl;
|
||||
}
|
||||
|
||||
location /stat.xsl {
|
||||
root /usr/local/nginx/html;
|
||||
}
|
||||
|
||||
# Frontend (Vite dev server) — catch-all
|
||||
location / {
|
||||
proxy_pass http://vod_frontend:5173;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
add_header Cache-Control no-cache; # prevent stale segments
|
||||
add_header Access-Control-Allow-Origin *; # CORS for browser playback
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user