The second server took a lot of work to get correct. It was much harder but the work payed off and it’s functional. I’m still trying to upgrade it to get better statistics about how many people are using the app to watch live but I have some going now.
To make this part function, the server takes in an RTMP stream and converts it using ffmpeg to make it an HLS .m3u8 file. That file is then the target of a link in the apps control panel that tells it to get the stream on a users phone and display our live service. Each user of the app who watches within the app is connected to the HLS streaming server and so we have to scale this one up to use it well.
I have a snapshot of the server that is in AWS Lightsale and when we need it I can spin it up to be what would cost $40 a month. But we only need it for a couple hours. Then we delete it. So it costs about 12 cents to run each week for our live service on Wednesday. I just transfer over the dns records and IP address information and allow the proper ports on the firewall and in 5 minutes it’s ready to go.
I also found data about statistics by searching for “stub_status Nginx” on Google. That led me to information such as: https://www.google.com/amp/s/easyengine.io/tutorials/nginx/status-page/%3Famp
The configuration is similar to the RTMP re-streamer in that they both use Ubuntu and NGINX and this one needs ffmpeg to do its conversions of the RTMP feed into the HLS feed for the app.
I used a tutorial I found online to begin this one as well. It’s found below.
After going around and around trying to recompile Nginx with the stub_status module, I found the tutorial that told me how to check if it was already installed. It turns out it was. So that was good however I wasted a lot of time trying to install it and a c compiler when I didn’t need to.
If you’d like to see my NGINX.conf file for the HLS streaming server an example of it is here. If you’d like it to also stream to other services you can use it, but you have to modify it a little bit like the RTMP server that I posted about previously. Facebook only accepts “secure” rtmp so you have to pass it’s feed through “stunnel”. Here’s my nginx.conf file. I also put in the “Streamingserver.xyz.conf” file that you will need in the sites-available folder on the server. This file should be named after your proper registered domainname and .com or .org or .xyz or whatever your domain name is. The default file below is “default” as seen in the sites-available folder on the server as well. These are all in “/etc/nginx/nginx.conf” or the others are in “/etc/nginx/sights-available/”. If you follow along in the examples that I gave above from the links to outside sites, you can see that you’ll make a link between the sites-available folder and two files in the sites-enabled folder with the same names of “default” and “yourserver.something.conf”. Also while I was creating this, I had to stop the apache server because it was interfering. I had to issue the command “sudo systemctl stop apache2”. It was causing errors.
If you’re interested in the app we use it’s The Church App from Subsplash.