How-to use NGINX as an edge from a Wowza origin

If you are trying to setup a solution to be low cost and effective, you can look at combining Wowza as an origin and NGINX as an edge. Below I depict one way to set it all up. Here I assume you are new to NGINX but have a solid Wowza grounding. This very basic tutorial is demonstrating an install on a CentOS 6.5 x64 linux distribution.

1. Install NGINX/RTMP module

rpm –import http://packages.atrpms.net/RPM-GPG-KEY.atrpms
rpm -ivh http://dl.atrpms.net/el6.9-x86_64/atrpms/stable/atrpms-repo-6-7.el6.x86_64.rpm
yum -y –enablerepo=atrpms install ffmpeg

Install some other pre-reqs since we will be compiling from source:

cd /root
yum -y install gcc gcc-c++ make zlib-devel pcre-devel openssl-devel git wget

Get the latest rtmp module via git:

git clone git://github.com/arut/nginx-rtmp-module.git

Obtain the latest nginx version and extract:

mkdir -p src
cd src
wget http://nginx.org/download/nginx-1.5.7.tar.gz
tar -xzf nginx-1.5.7.tar.gz
cd nginx-1.5.7

Compile & install NGINX:

./configure –user=nginx –group=nginx –prefix=/etc/nginx –sbin-path=/usr/sbin/nginx –conf-path=/etc/nginx/nginx.conf –pid-path=/var/run/nginx.pid –lock-path=/var/run/nginx.lock –error-log-path=/var/log/nginx/error.log –http-log-path=/var/log/nginx/access.log –with-http_gzip_static_module –with-http_stub_status_module –with-http_ssl_module –with-pcre –with-file-aio –with-http_realip_module –add-module=/root/nginx-rtmp-module/
make
make install
chmod +x /etc/init.d/nginx

Start your nginx service:

chkconfig nginx on
service nginx start

Note: You may need to add types_hash_bucket_size 64; to your /etc/nginx/nginx.conf file

Some other useful commands:

#reload nginx
nginx -s reload

#restart
service nginx restart

#stop
service nginx stop

#start
service nginx start

#sometimes residual processes to not close properly, try the following
killall nginx

2. Setup Wowza

Simply setup a basic Wowza install and publish a stream to it.

3. Setup on-demand configuration

You will need to modify your nginx.conf to set this part up. Simply define the following:

application pullfromwowza {
  live on;
  pull rtmp://[your-wowza-ip]:1935/[app];
}

This should do a dynamic pull based on demand. Once this modification has been made, reload nginx (see above command). Then you can playback as follows:

rtmp://[your-nginx-ip]:1935/pullfromwowza/[published-stream-name-from-wowza]

This should do a dynamic pull based on demand. As a complete basic nginx.conf file, it would look something like:

worker_processes  1;
events {
    worker_connections  1024;
}
rtmp {
    server {
        listen 1935;
        application pullfromwowza {
           live on;
           pull rtmp://[your-wowza-ip]:1935/[app];
        }
     }
}

Note: This will only work via RTMP from nginx.


Comments are closed.