HLS Streaming Server with NGINX

  • 1,059 views. Added .

Want to make your own streaming server so you can deliver live HTTP video to your website? Grab a VPS and strap in, because it's easier than you might think!

Affiliate links for DigitalOcean and Linode:

Guide used as a reference for this video (not comprehensive): https://docs.peer5.com/guides/setting-up-hls-live-streaming-server-using-nginx/

Currently-maintained NGINX RTMP module fork: https://github.com/sergey-dryabzhinsky/nginx-rtmp-module

Comments (log in to post)

Hi Jacob,

First of all thank you so much for producing these videos. So much heartache avoided by clean and robust tutorials. A very welcome godsend.

I am struggling to make hls stream over https.

I have followed your previous video to the letter and have live streaming and restreaming over http.

I am also using Digital Ocean and LetsEncrypt. I have the certificates installed and from this video above I can see these in the appropriate folder. I have added, as per your instructions, the locations within nginx.conf.

I generally use "sudo systemctl restart nginx" with no errors; but have checked using your syntax and can see .m3u8 data being created.

I am a a complete loss and been at this https challenge for four days solid.

I'd be very grateful if you could shed some light or pointers to get this moving.

Watching your video again I've carefully went over the steps and the debugging protocols you use.

My server video is showing a 404 error but attributed to nginx 1.14, which I know is the Digital Ocean version, which I've never installed but somehow its in there. Note that my http stream works.

I ran your commands, found around 25 minutes in, to purge python-certbox-nginx:

root@200630-hls-restream-nohttps-s-1vcpu-2gb-lon1-01:~# sudo apt purge python-certbox-nginx
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package python-certbox-nginx
root@200630-hls-restream-nohttps-s-1vcpu-2gb-lon1-01:~# sudo apt remove nginx*
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package nginx-1.19.0
E: Couldn't find any package by glob 'nginx-1.19.0'
E: Couldn't find any package by regex 'nginx-1.19.0'
E: Unable to locate package nginx-rtmp-module

I can restart nginx and can send a stream to it, but again I have this nginx 1.14 404 error.

Your video goes too quick for me to see how to remove nginx1.14 and I'm now scared to touch anything :-D

I've also posted on this video's forum thread.

Hi Jacob,

Excellent tutorial!  Quick question, still having an issue with sending the HLS data into my web site, the player keeps going into a loading loop after hitting 'play'.  RTMP seems to be working, able to open the stream in VLC (rtmp://mydomain:8080/show/live.m3u8).   Do I need to add anything under the http or HLS/application sections of the nginx.conf or could I be missing something else?

Ubuntu: 18.04
Nginx: 1.14 (hosting both www and rtmp)

Thanks in advance for your help and stay safe.

I would assume you need to be able to play back the m3u8 feed using http:// or https:// (whichever your website is using) and without specifying port 8080:. You need to add the things under the http section that I added in this video. A web browser needs to be able to visit the .m3u8 link and download the m3u8 manifest. If it can, then a video player should be able to play the video back as well.
Thanks a lot Jacob, it is working now.
Nice tutorial.
Do you have some similar stream solution, for webrtc?
Good afternoon Jacob, I hope you are well.

I tell him I managed to implement my HLS server, and now that I buy a decoder to see the transmission that is sent to the server through RTMP, the decoder does not connect to the server since it only recognizes formatted addresses:

transmission link: rtmp: //rtmp.mine.com.cn/live/0315
reproductor link: rtmp: //pay.mine.com.cn/live/0315

Do you think there was a solution?
Hi there!

marpensa said

now that I buy a decoder to see the transmission
Why do you need to buy a decoder? ffmpeg is the encoder, NGINX is the transcoder, the web browser is the decoder. All major web browsers are currently able to play HLS, and even the ones that can't natively can do so through a video player like VideoJS.

marpensa said

transmission link: rtmp: //rtmp.mine.com.cn/live/0315
reproductor link: rtmp: //pay.mine.com.cn/live/0315
"Reproductor" is not an English word, but I get the idea. However, your playback URL is not going to start with rtmp:, it's going to start with http: or https: (hence, why it's called HTTP Live Streaming) and it's going to end with .m3u8. You can play back the RTMP URL using a player that can decode RTMP, but the point of this video and the setup I demonstrated was to have NGINX decode it into HLS so clients can watch directly. Does that make sense? If not, then I'd need some more clarification on what you're trying to accomplish.