$def with (run_dir, ip, onions, domains)
user admin admin;
load_module "modules/ngx_rtmp_module.so";
worker_processes auto;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
types_hash_max_size 2048;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
server_tokens off;
server_names_hash_bucket_size 128;
gzip on;
map $$http_upgrade $$connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name $ip$"".join([f" {d} www.{d}" for d in domains]);
include acme-challenge.conf;
location / {
return 308 https://$$host$$request_uri;
}
}
server {
listen 80;
listen [::]:80;
server_name $" ".join(onions);
include application.conf;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name $ip;
ssl_certificate $run_dir/certs/selfsigned-ip.crt;
ssl_certificate_key $run_dir/certs/selfsigned-ip.key;
include ssl-params.conf;
include application.conf;
}
$for domain, active in domains.items():
$if not active:
$continue
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name $domain www.$domain;
if ($$host = "www.$domain") {
return 308 https://$$host$$request_uri;
}
ssl_certificate $run_dir/certs/$domain/domain.crt;
ssl_certificate_key $run_dir/certs/$domain/domain.key;
include ssl-params.conf;
include acme-challenge.conf;
include application.conf;
}
}
$ streaming_dir = f"{run_dir}/media/streaming"
rtmp {
hls on;
hls_path $streaming_dir/hls;
hls_fragment 5s;
record all;
record_path $streaming_dir/rec;
record_suffix _%Y-%m-%d_%H-%M-%S.flv;
record_lock on;
exec_publish $streaming_dir/publish.sh;
exec_record_done $streaming_dir/finished.sh $$path $$basename.mp4;
access_log /var/log/nginx/rtmp_access.log combined;
access_log on;
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record all;
# push rtmp://localhost/twitch;
# push rtmp://localhost/youtube;
}
application twitch {
live on;
record off;
allow publish 127.0.0.1;
deny publish all;
push rtmp://lax.contribute.live-video.net/app/live_784014614_hwNuA2Gl5fz3SxETlrFcMmk0H2qynG;
}
application youtube {
live on;
record off;
allow publish 127.0.0.1;
deny publish all;
push rtmp://a.rtmp.youtube.com/live2/4505-6umr-xemj-tm3g-959h;
}
}
}
# leave this here for cat'ing over SSH...