diff --git a/nginx/Dockerfile b/nginx/Dockerfile new file mode 100644 index 0000000..92121a3 --- /dev/null +++ b/nginx/Dockerfile @@ -0,0 +1,6 @@ +FROM tiangolo/nginx-rtmp + +COPY nginx.conf /etc/nginx/nginx.conf + +EXPOSE 1935 +EXPOSE 8080 diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..2b7e71a --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,83 @@ +worker_processes auto; +events { + worker_connections 1024; +} + +rtmp { + server { + listen 1935; + chunk_size 4096; + + application live { + live on; + record off; + + allow publish all; + allow play all; + + hls on; + hls_path /tmp/hls; + hls_fragment 3; + hls_playlist_length 60; + } + } +} + +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; + + # 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; + } + 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; + } + } +}