1. Environment construction
1. Download
https://github.com/winshining/nginx-http-flv-module
After selecting the version, download the zip package. Upload to server.
2. Install
unzip nginx-http-flv-module-1.2.10.zip
#rename module
mv nginx-http-flv-module-1.2.10 nginx-http-flv-module
#Enter the nginx decompressed folder
cd /usr/local/nginx-1.18.0/
#Move the module position
mv /usr/local/project/nginx-http-flv-module /usr/local/
# Add module to nginx
./configure --add-module=/usr/local/nginx-http-flv-module
#Compile and install
make
make install
3. Modify nginx configuration
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';
}
}
}
restart nginx
cd /usr/local/nginx/sbin/
./nginx -c /usr/local/nginx/conf/nginx.conf
2. Test
Same as the test method below, just modify the vlc streaming address