sudo apt update
sudo apt install build-essential libpcre3 libpcre3-dev libssl-dev nginx libnginx-mod-rtmp ffmpeg -y
sudo nano /etc/nginx/nginx.conf
rtmp {
server {
listen 1935;
chunk_size 4096;
notify_method get;
application live {
live on;
##Set this to "record off" if you don't want to save a copy of your broadcasts
record off;
#record all;
## The directory in which the recordings will be stored
## mkdir -p /var/www/html/recordings
## chown -R www-data:www-data /var/www/html/recordings/
#record_path /var/www/html/recordings;
#record_unique on;
on_publish http://127.0.0.1/auth;
#on_publish http://127.0.0.1/public;
}
}
}
sudo nano /etc/nginx/sites-enabled/default
location /auth {
if ($arg_pwd = 'a_secret_password') {
return 200;
}
return 401;
}
location /public {
return 200;
}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
# Allow access from any visitor
allow all;
# Live updates for the stat page
add_header Refresh "3; $request_uri";
}
location /stat.xsl {
root /var/www/;
}
location /control {
rtmp_control all;
# Enable CORS
add_header Access-Control-Allow-Origin * always;
}
sudo systemctl restart nginx
cd /var/www/
sudo wget https://rawgit.flutter-io.cn/arut/nginx-rtmp-module/master/stat.xsl
推流地址:
rtmp://192.168.0.xxx:1935/live/stu?pwd=password
拉流地址:
rtmp://192.168.0.xxx:1935/live/stu