Facebook is planning to deprecate RTMP on May 1st on their Live API. They’re encouraging users that use the streaming tool to use RTMPS, a more secure version of RTMP that includes TLS/SSL (a set cryptographic protocols for secure communication).
Unfortunately, as of now, NGINX module nginx-rtmp-module doesn’t support RTMPS “out-of-the-box”. I opened an issue on GitHub on the plugin page and thanks to Liu Lantao, he devised an easy way to incorporate RTMPS into this module by using stunnel, a popular “application used to provide a universal TLS/SSL tunneling service”.
This article focuses on how to use stunnel to stream RTMPS such as Facebook Live with NGINX on Windows. For this setup, I’m using nginx 1.7.11.3 Gryphon (download here) on Windows 10.
Start by downloading and installing stunnel for Windows (download here). After you installed stunnel, you need to edit stunnel.conf which is located in
C:\Users\YourUsername\AppData\Local\stunnel\config\stunnel.conf
Note: You can also type in ‘edit stunnel.conf’ in the search bar and it will open up Notepad for you!
Now add the following lines to end of stunnel.conf. This creates a session that allows NGINX to send the stream via RTMP and stunnel will then send the stream to Facebook via RTMPS.
[fb-live] client = yes accept = 127.0.0.1:1935 connect = live-api-s.facebook.com:443 verifyChain = no
Now modify nginx.conf and replace the old Facebook push instruction (if you had it there before) with the following line:
push rtmp://127.0.0.1:1935/rtmp/<your_facebook_stream_key>;
Save those two files and start stunnel via command-line or with the GUI application and then start nginx. Test your live stream with OBS ( instructions are under the testing section) or ffmpeg (instructions are in second to last code block). That’s all there is to it!
From a high level, stunnel and NGINX should now operate like this:
____________ ____________ ____________ ____________ | Streaming | | | | | | Facebook | | Source | ---> | NGINX | ---> | stunnel | ---> | Live | |____________| |____________| |____________| |____________|