On Debian (and may be others, I did not test it) we have different complied version of Nginx. You can search it using
then you will see a line link this
which simply says we have three versions for installing
nginx-light
nginx-full
nginx-extras
and the deference between them is with the number of modules have been complied to have the binary file. For having less headache you can install nginx-extras so most required modules already complied into it.
If you already have install Nginx, you can check the list of modules complied with Nginx using nginx -V
or you can grep to see rtmp support
We can install Nginx using default Debian packages or using separate Nginx repository. After installing Nginx make sure it is up and running and load the IP or domain name you have to see the Welcome to nginx! page.
Check list of Nginx modules
Now we should check if we have rtmp shared library or not. First check the location
Then check the modules, here you can see I have it ngx_rtmp_module.so at the bottom
if you did not have, check the next step
Install rtmp modules on Debian
If you did not have the modules, search for it :)
Here is the module libnginx-mod-rtmp so install it
and then check the Nginx's modules location to see if we have ngx_rtmp_module.so or not. WE SHOULD HAVE IT.
After you install the ngx_rtmp_module.so modules restart or reload Nginx to make sure everything is working fine
Config nginx.conf file
Go to /etc/nginx/ directory and open up nginx.conf file. We should add RTMP configuration to nginx.conf file
Here is the configuration
and the RTMP server
Some notes
It has its own server block
Port is 1935 by default
for each stream we have an application which is show
create this path /var/www/live/hls for save chuck of vidoes
other options can be vary depending on your requirements
Our web server root path will be /var/www/live
As last step for this section, reload Nignx and make sure everything is fine.
Also here is the complete nginx.conf file if you want to check everything with mine.
Setting up a domain name (optional)
We can have our own domain to load the website or just using an IP address. I already have tested with IP address and preferred to have a domain name so I used live.shakiba.net
Setting up SSL/TLS and HTTPS for domain (optional)
We do not have to do so, but again I preferred to have it. You can use any CDN provider and most of them support Free SSL using Lets Encrypt to issue 90 days certificate. So mine endpoint will be https://live.shakiba.net
Configure live.shakiba.net file in sites-available/
Since my chosen domain is live.shakiba.net I will use this name, you have your own. You can see bellow I have the file
basic configuration to check the load of the domain
root directory we have set up is /var/www/live so make sure you have it and add a sample index.html to the location which means we will have /var/www/live/index.html
reload or restart Ningx the load your own domain name or IP address ir you did not have domain name and have set it up on your localhost
Here is a screenshot of mine which I made it fancy, of course you do not have to make it fancy.
# the module we installed
# We do not have to load it explicitly
# load_module modules/ngx_http_js_module.so;
# RTMP configuration
rtmp {
server {
listen 1935; # Listen on standard RTMP port
chunk_size 4000;
application show {
live on;
# Turn on HLS
hls on;
hls_path /var/www/live/hls;
hls_fragment 3;
hls_playlist_length 60;
# disable consuming the stream from nginx as rtmp
deny play all;
}
}
}