
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 20s
120 lines
3.6 KiB
Nginx Configuration File
120 lines
3.6 KiB
Nginx Configuration File
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
include /etc/nginx/mime.types;
|
|
default_type application/octet-stream;
|
|
|
|
sendfile on;
|
|
tcp_nopush on;
|
|
tcp_nodelay on;
|
|
keepalive_timeout 65;
|
|
gzip on;
|
|
|
|
# Cache settings for HLS
|
|
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=hls_cache:10m max_size=1g inactive=60m use_temp_path=off;
|
|
|
|
server {
|
|
listen 8880;
|
|
server_name _;
|
|
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# Health check
|
|
location /health {
|
|
access_log off;
|
|
return 200 "OK\n";
|
|
add_header Content-Type text/plain;
|
|
}
|
|
|
|
# Main web interface
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
}
|
|
|
|
# HLS streams proxy
|
|
location /hls/ {
|
|
proxy_pass http://[::1]:8888/;
|
|
proxy_http_version 1.1;
|
|
|
|
# Forward authentication headers
|
|
proxy_set_header Authorization $http_authorization;
|
|
|
|
# CORS headers
|
|
add_header Access-Control-Allow-Origin *;
|
|
add_header Access-Control-Allow-Methods "GET, OPTIONS";
|
|
add_header Access-Control-Allow-Headers "Range, Authorization";
|
|
|
|
# Cache HLS segments
|
|
proxy_cache hls_cache;
|
|
proxy_cache_valid 200 1m;
|
|
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
|
|
|
proxy_buffering off;
|
|
proxy_request_buffering off;
|
|
}
|
|
|
|
# WebRTC signaling (WHEP)
|
|
location /webrtc/ {
|
|
proxy_pass http://[::1]:8889/;
|
|
proxy_http_version 1.1;
|
|
|
|
# CORS headers for WebRTC
|
|
add_header Access-Control-Allow-Origin * always;
|
|
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS, PATCH, DELETE" always;
|
|
add_header Access-Control-Allow-Headers "Authorization, Content-Type, If-Match" always;
|
|
add_header Access-Control-Expose-Headers "Link" always;
|
|
|
|
# Handle OPTIONS preflight
|
|
if ($request_method = OPTIONS) {
|
|
return 204;
|
|
}
|
|
|
|
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;
|
|
proxy_set_header Authorization $http_authorization;
|
|
|
|
proxy_buffering off;
|
|
proxy_request_buffering off;
|
|
proxy_read_timeout 86400;
|
|
proxy_send_timeout 86400;
|
|
}
|
|
|
|
# MediaMTX API
|
|
location /api/mediamtx/ {
|
|
proxy_pass http://[::1]:9997/;
|
|
allow 127.0.0.1;
|
|
allow 172.16.0.0/12;
|
|
deny all;
|
|
}
|
|
|
|
# Recordings
|
|
location /recordings/ {
|
|
alias /recordings/;
|
|
autoindex on;
|
|
autoindex_exact_size off;
|
|
autoindex_localtime on;
|
|
add_header Accept-Ranges bytes;
|
|
add_header Content-Disposition "inline";
|
|
}
|
|
|
|
# API endpoint for recordings list
|
|
location /api/recordings {
|
|
default_type application/json;
|
|
return 200 '{"recordings": []}';
|
|
}
|
|
|
|
# Metrics
|
|
location /metrics {
|
|
proxy_pass http://localhost:9998/metrics;
|
|
allow 127.0.0.1;
|
|
allow 172.16.0.0/12;
|
|
deny all;
|
|
}
|
|
}
|
|
} |