How to set up your own private RTMP server using nginx

All Versions How to set up your own private RTMP server using nginx

zibingala

New Member
Hi Guys,
I have a couple of basic questions, wondering if you can help me with:

config file:
Code:
rtmp {
        server {
                listen 1935;
                chunk_size 4096;

                application live {
                        live on;
                        record off;
                }
        }
}

1) I want 3 friends be streaming to my rtmp server, to include them on my OBS live streaming via brower. Is this config enough?
2) I want to secure the server, to avoid anyone having the IP using it. How can I do that?

Thanks in advance!!
ff

yey! I have the same issue guys... it seems pretty basic for me too, but I can't get through the same phase.

I have the rtmp working on my local network - and I am able to stream into it locally (checking it with VLC also works)

But I can't feed it "via internet" from different network.
1.) I would like to setup an OBS on an other computer (and network) to feed video&sound into my RTMP
(I already tried to add "Inbound exception" for the port 1935 at Windows Firewall on the server PC
+ I tried to send the stream to the IP I found for the server at https://www.myglobalip.com/ )
2.) Feed that RTMP into my OBS
3.) From which I will stream to youtube or whatever but I can already handle that luckily(:

And lots of thanks in advance in these difficult times!
 

L0rdG1gabyt3

New Member
yey! I have the same issue guys... it seems pretty basic for me too, but I can't get through the same phase.

I have the rtmp working on my local network - and I am able to stream into it locally (checking it with VLC also works)

But I can't feed it "via internet" from different network.
1.) I would like to setup an OBS on an other computer (and network) to feed video&sound into my RTMP
(I already tried to add "Inbound exception" for the port 1935 at Windows Firewall on the server PC
+ I tried to send the stream to the IP I found for the server at https://www.myglobalip.com/ )
2.) Feed that RTMP into my OBS
3.) From which I will stream to youtube or whatever but I can already handle that luckily(:

And lots of thanks in advance in these difficult times!
Have you checked your firewall? Make sure you have port forwarding set for 1935 to your server.
 

Mark Weiss

Member
With the increasing censorship on commercial streaming sites, I would really like to crack the problem of making my own streaming site, totally independent of the corporate controlled, government controlled media platforms.
In 2003, I was able to stream online with a Sony GRX560 laptop running Windows Media Encoder and a Sony VX2000 video camera. Today, there seems to be no modern version of WME.
The only "alternative" I keep hearing about is nginx, but a commercial license is out of the question, financially, and the creators won't help non-paying users beyond a few simple clues, not enough to make it work.
What else is out there in the past year that can make this task more user friendly, especially for us octogenarians? A modern Windows Media Encoder would be great, but MS stopped offering that software a decade and a half ago.
 

ldngeez

New Member
Just checking in in 2020 (7 years later!!!!) to say thanks for the guide. Just followed this and it works perfectly.

I set up the RTMP server on a fresh install of Ubuntu Server on an old Lenovo T61 and it was able to relay a stream from my friend's house to my OBS, crisp and clear with only about 3 seconds of delay. Amazing.

Your guide lives on. Much appreciated.

Also, for anyone reading from the future, we're currently under quarantine from Covid-19, during which there is an incredible and sudden interest in live-streaming, since physical social gatherings are prohibited. Musicians and preachers and yoga teachers are all going live and people like me are tinkering like mad.

Hi @pronghorn ,

Glad it worked for you. Can you help me? I can do everything internally but i don't know how to make it work from my friends house like you? That would be great if you can help me out bro.
 
Last edited:

ldngeez

New Member
Hi @pronghorn ,

Glad it worked for you. Can you help me? I can do everything internally but i don't know how to make it work from my friends house like you? That would be great if you can help me out bro.

Fixed! Don't ask me how.. had to redo the whole server configuration.. must've missed something somewhere. Now i can stream to server and see on VLC but when my friend streams from his house it shows that it's streaming but i have no way of checking if the connection is actually streaming to my nginx, he can see the splash page but when i open the stream on VLC it doesn't show the stream, but if i start streaming it shows straight away... strange. Have to figure out what is happening.
 

Aerial

New Member
So far, so good! The original build recipe works perfectly (if you change the NGINX version). For some of the complaints above, you have to go onto the NGINX site and see what is the most recent version of the server. For Ubuntu installs, be sure you've installed zlib before you try to do the make.
So...not that I mind a bit of tech sweat ;) but...
Does anybody have a clause for the nginx.conf that will allow it to transcode (for other containers, etc. using ffmpeg)? I thought I just saw it in the docs for the server module but I can't find it now...?
 

Marcel Gavalier

New Member
Code:
root@debian:~/restreamer_nginx_2/nginx-1.16.1# sudo /usr/local/nginx/sbin/nginx
nginx: [emerg] dlopen() "/usr/local/nginx/modules/ngx_http_auth_pam_module.so" failed (/usr/local/nginx/modules/ngx_http_auth_pam_module.so: cannot open shared object file: No such file or directory) in /etc/nginx/modules-enabled/50-mod-http-auth-pam.conf:1

After step by step i got this....

is becouse no modules there

Code:
root@debian:~# cd /usr/local/nginx/
client_body_temp/ fastcgi_temp/     logs/             sbin/             uwsgi_temp/       
conf/             html/             proxy_temp/       scgi_temp/       
root@debian:~# cd /usr/local/nginx/
 

acupofjose

New Member
@dodgepong thank you so much for this tutorial! Really it's been a huge help.

I set up a `Dockerfile` and `docker-compose.yml` for easier reproducibility of building nginx from source with the rtmp module attached to it. I'll leave a link for anyone might benefit from it.

 

arthurtully

New Member
I will use this to stream remotely to my PC and from my PC to twitch.
Default setup of nginx with these settings in the config: https://pastebin.com/HgWqBP0L
Use NGINX Lizard and rename nginx-win.conf to just nginx.conf for it to work.
You will need to portforward 1935. Use this to check: https://www.yougetsignal.com/tools/open-ports/
For iOS side use Larix Broadcaster app with these settings: rtmp://*YOURIP*/live/stream
Install VLC and add a VLC source to OBS with: rtmp://127.0.0.1/live/stream

You have a livestream directly from your phone with all your alerts and everything.
Tip: use anydesk app to remotely control your PC if you need to fix something on the go and use jailbreak to enable multitasking.

If you have any questions catch me live on twitch and i'll make sure to answer them.
 

ermannobonifazi

New Member
I have ngix correctly sending the stream to FB but in the Content Creator page, and GO LIVE in Content Creator must be clicked manually, while in Twich and YT the stream start automatically. Anybody know how to achieve the same result and start automatically?
 

Mark Weiss

Member
Youtube stream no longer starts automatically for me. I have to go into Youtube Studio and set up a live stream first now.
 

unusualcrow

New Member
I can't access the stream from outside my network, but within my network I can. I also cannot stream to my public ip.

Accessing through rtmp://192.168.1.186/live/test works, but rtmp://(my network ip):1935/live/test does not
Is there something that needs to be added to the config shown in this guide for this to work? Do I somehow need to push it? I'm not very savvy with networking so I don't know what's wrong here. Port 1935 is open on my network and I've verified this. The server is Ubuntu Server on a Raspberry Pi 3 so there should be no firewall in the way.
Any help would be GREATLY appreciated!
 

Lilrex

Member
How do you set it up to connect via external IP ? currently I can do it just fine via internal LAN.

Also, do you need to have stream keys if you want to use multiple devices? How do you generate and check a stream key?
 

Lilrex

Member
has anyone really dialed in their RTMP settings and are willing to share? I have been going through the RTMP documentation but it is rather extensive and being so new a little overwhelming.
 
Top