1.环境搭建
1.下载
https://github.com/winshining/nginx-http-flv-module
选择版本后,下载zip包。上传到服务器。
2.安装
unzip nginx-http-flv-module-1.2.10.zip
#重命名模块
mv nginx-http-flv-module-1.2.10 nginx-http-flv-module
#进入nginx解压后的文件夹
cd /usr/local/nginx-1.18.0/
#移动模块位置
mv /usr/local/project/nginx-http-flv-module /usr/local/
#模块添加到nginx
./configure --add-module=/usr/local/nginx-http-flv-module
#编译安装
make
make install
3.修改nginx配置
rtmp_auto_push on;
# 添加RTMP服务
rtmp {
server {
listen 1935;
application live {
live on;
}
}
}
# 添加http-flv服务
http {
server {
listen 8080;
server_name localhost;
location /live {
flv_live on;
chunked_transfer_encoding on; #open 'Transfer-Encoding: chunked' response
add_header 'Access-Control-Allow-Credentials' 'true'; #add additional HTTP header
add_header 'Access-Control-Allow-Origin' '*'; #add additional HTTP header
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
add_header 'Cache-Control' 'no-cache';
}
}
}
重启nginx
cd /usr/local/nginx/sbin/
./nginx -c /usr/local/nginx/conf/nginx.conf
2.测试
同下面测试方法一致,修改vlc拉流地址即可