137 lines
3.8 KiB
Nginx Configuration File
137 lines
3.8 KiB
Nginx Configuration File
worker_processes 1;
|
|
error_log /var/log/nginx/error.log warn;
|
|
|
|
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/init_stream; # if the stream is detected from OBS
|
|
on_publish_done http://web_server:5000/end_stream; # if the stream is ended on OBS
|
|
|
|
}
|
|
|
|
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 2s;
|
|
hls_playlist_length 6s;
|
|
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/stream/$1/$2;
|
|
|
|
# Let the MPEG-TS video chunks be cacheable
|
|
expires max;
|
|
}
|
|
|
|
# The M3U8 playlists location
|
|
location ~ ^/stream/(.+)/(.+\.m3u8)$ {
|
|
alias /stream_data/stream/$1/$2;
|
|
|
|
# The M3U8 playlists should not be cacheable
|
|
expires -1d;
|
|
}
|
|
|
|
## The thumbnails location
|
|
location ~ ^/stream/(.+)/thumbnails/(.+\.png)$ {
|
|
alias /stream_data/stream/$1/$2;
|
|
|
|
# The thumbnails should not be cacheable
|
|
expires -1d;
|
|
}
|
|
|
|
## The vods location
|
|
location ~ ^/stream/(.+)/vods/(.+\.mp4)$ {
|
|
alias /stream_data/vods/$1/$2;
|
|
|
|
# The vods should not be cacheable
|
|
expires -1d;
|
|
}
|
|
|
|
## Profile pictures location
|
|
location ~ ^/user/(.+)/profile_picture$ {
|
|
alias /stream_data/profile_pictures/$1.png;
|
|
|
|
# The profile pictures 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";
|
|
}
|
|
}
|
|
}
|