120 lines
3.3 KiB
Nginx Configuration File
120 lines
3.3 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 /stream_data/;
|
|
|
|
allow publish 127.0.0.1;
|
|
deny publish all;
|
|
|
|
hls_nested on;
|
|
hls_fragment 5s;
|
|
hls_playlist_length 60s;
|
|
hls_fragment_naming system;
|
|
hls_cleanup off;
|
|
}
|
|
}
|
|
}
|
|
|
|
http {
|
|
access_log off;
|
|
# Enable HLS
|
|
server {
|
|
listen 8080;
|
|
root /var/www;
|
|
|
|
location /api/ {
|
|
rewrite ^/api/(.*)$ /$1 break;
|
|
proxy_pass http://web_server:5000; # flask-app is the name of the Flask container in docker-compose
|
|
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;
|
|
}
|
|
|
|
location /socket.io/ {
|
|
proxy_pass http://web_server:5000/socket.io/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
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_cache_bypass $http_upgrade;
|
|
proxy_buffers 8 32k;
|
|
proxy_buffer_size 64k;
|
|
proxy_read_timeout 86400;
|
|
}
|
|
|
|
location /hmr/ {
|
|
proxy_pass http://frontend:5173;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Host $host;
|
|
}
|
|
|
|
# The MPEG-TS video chunks are stored in /tmp/hls
|
|
location ~ ^/stream/(.+)/(.+\.ts)$ {
|
|
alias /stream_data/$1/stream/$2;
|
|
|
|
# Let the MPEG-TS video chunks be cacheable
|
|
expires max;
|
|
}
|
|
|
|
# The M3U8 playlists location
|
|
location ~ ^/stream/(.+)/(.+\.m3u8)$ {
|
|
alias /stream_data/$1/stream/$2;
|
|
|
|
# The M3U8 playlists should not be cacheable
|
|
expires -1d;
|
|
}
|
|
|
|
# The thumbnails location
|
|
location ~ ^/stream/(.+)/thumbnails/(.+\.jpg)$ {
|
|
alias /stream_data/$1/thumbnails/$2;
|
|
|
|
# The thumbnails should not be cacheable
|
|
expires -1d;
|
|
}
|
|
|
|
location ~ ^/\?token=.*$ {
|
|
proxy_pass http://frontend:5173;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Host $host;
|
|
}
|
|
|
|
location / {
|
|
proxy_pass http://frontend:5173;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
}
|
|
}
|
|
}
|