Linux Programmer | RHCE | RHCSA

Search This Blog

enable nginx-http-flv module | Nginx | RTMP | Streaming | Live Streaming | FLV video

 Purpose:

Compile nginx-flv module with nginx so that video can be play on web browser with http link.


Installation - 

  1. Download Nginx source code from stable version.

http://nginx.org/en/download.html

  1. Download nginx-http-flv-module from latest master branch.

https://github.com/winshining/nginx-http-flv-module

Download link - 

https://codeload.github.com/winshining/nginx-http-flv-module/zip/refs/heads/master


  1. Now compile source code.

./configure --add-module=/home/$user/nginx-http-flv-module-master

make

sudo make install


This is installed on below location,

/usr/local/nginx


Below is the nginx confirmation file with FLV configuration and SSL.

File location - /usr/local/nginx/conf


Nginx.conf

#user  nobody;

worker_processes  1;


#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;


#pid    logs/nginx.pid;


#load_module modules/ngx_http_flv_live_module.so;


events {

worker_connections  4048;

}



http {

include   mime.types;

default_type  application/octet-stream;


#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

#              '$status $body_bytes_sent "$http_referer" '

#              '"$http_user_agent" "$http_x_forwarded_for"';


#access_log  logs/access.log  main;


sendfile    on;

#tcp_nopush on;


#keepalive_timeout  0;

keepalive_timeout  65;


#gzip  on;


server {

     listen   80;

     server_name  localhost;


     #charset koi8-r;


     #access_log  logs/host.access.log  main;



     location / {

         root   html;

         index  index.html index.htm;

     }


     #error_page  404          /404.html;


     # redirect server error pages to the static page /50x.html

     #

     error_page   500 502 503 504  /50x.html;

     location = /50x.html {

         root   html;

     }


     location /live {

         flv_live on;

         chunked_transfer_encoding on;


         add_header 'Access-Control-Allow-Origin' '*';

         add_header 'Access-Control-Allow-Credentials' 'true';

     }



    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 "10; $request_uri";

    }


    location /stat.xsl {

     root html;

    }


#    location /hls {

#        types {

#            application/vnd.apple.mpegurl m3u8;

#            video/mp2t ts;

#        }


#        root /tmp;

#        add_header 'Cache-Control' 'no-cache';

#    }


#    location /dash {

#        root /tmp;

#        add_header 'Cache-Control' 'no-cache';

#    }



     # proxy the PHP scripts to Apache listening on 127.0.0.1:80

     #

     #location ~ \.php$ {

     # proxy_pass   http://127.0.0.1;

     #}


     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

     #

     #location ~ \.php$ {

     # root       html;

     # fastcgi_pass   127.0.0.1:9000;

     # fastcgi_index  index.php;

     # fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

     # include    fastcgi_params;

     #}


     # deny access to .htaccess files, if Apache's document root

     # concurs with nginx's one

     #

     #location ~ /\.ht {

     # deny  all;

     #}

}



########### SSL settings ###################

server {

         listen  443 ssl;

         listen  [::]:443 ssl;

         server_name  server.url.com;


         ssl_certificate /usr/local/nginx/ssl/wildcard/emc-combine.crt;

         ssl_certificate_key /usr/local/nginx/ssl/wildcard/emc.key;


         # SSL Settings

         ssl_ciphers HIGH:!aNULL:!MD5;

         ssl_prefer_server_ciphers on;


         ssl_session_cache   shared:SSL:20m;

         ssl_session_timeout 30m;


         # OCSP stapling

         ssl_trusted_certificate /usr/local/nginx/ssl/wildcard/emc-ca.crt;


         location / {

            root   html;

            index  index.html index.htm;

         }


     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 "10; $request_uri";

     }

    

     location /stat.xsl {

         root html;

     }


}

########### SSL settings ###################

}



rtmp_auto_push on;

rtmp_auto_push_reconnect 1s;

rtmp_socket_dir /tmp;


rtmp {

     out_queue       4096;

     out_cork        8;

     max_streams     128;

     timeout         15s;

     drop_idle_publisher 15s;


     server {

             listen 1935;

             chunk_size 4096;


#   application hls {

#            live on;

#            hls on;

#               hls_path /var/www/html/live/;

#        }


       ########### FLV related settings ###########

    application live {

             live on;

             gop_cache on;

    }


#   application dash {

#   live on;

#   dash on;

#   dash_path /tmp/dash;

#   }


     }

}



To start nginx:

cd /usr/local/nginx/sbin

sudo ./nginx


To stop nginx:

PID=$(ps -ef | grep -i nginx | grep -v grep | awk '{print$2}' | tr '\n' ' ')

Kill -9 $PID

No comments:

Post a Comment

SSH not working with password after upgrade ubuntu 22.04

Issue: In recent upgrade of ubuntu 22.04 we are not able to login server with SSH password. but when we try to login with key then it allow...