Files
gander/nginx/nginx.conf
2025-01-30 03:50:58 +00:00

80 lines
1.8 KiB
Nginx Configuration File

worker_processes 1;
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935; # RTMP listen port
application live {
live on;
# No RTMP playback
deny play all;
push rtmp://127.0.0.1:1935/hls-live;
on_publish http://web_server:5000/publish_stream;
on_publish_done http://web_server:5000/end_stream;
}
application hls-live {
live on;
hls on;
hls_path /tmp/hls;
allow publish 127.0.0.1;
deny publish all;
hls_nested on;
hls_fragment 5s;
hls_playlist_length 60s;
}
}
}
http {
access_log off;
# Enable HLS
server {
listen 8080;
root /var/www;
# The MPEG-TS video chunks are stored in /tmp/hls
location ~ ^/stream/user/(.+\.ts)$ {
alias /tmp/hls/$1;
# Let the MPEG-TS video chunks be cacheable
expires max;
}
# The M3U8 playlists location
location ~ ^/stream/user/(.+\.m3u8)$ {
alias /tmp/hls/$1;
# The M3U8 playlists should not be cacheable
expires -1d;
}
location /api/ {
rewrite ^/api/(.*)$ /$1 break;
proxy_pass http://web_server:5000; # flask-app is the name of the Flask container in docker-compose
}
location /socket.io/ {
proxy_pass http://web_server:5000/socket.io/;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location / {
proxy_pass http://frontend:5173; # frontend is the name of the React container in docker-compose
}
}
}