ubuntu搭建rtmp-nginx服务器 拉流推流

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值