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

A somewhat advanced guide for Linux-based servers

  1. dodgepong Administrator

    Admin

    dodgepong submitted a new resource:

    How to set up your own private RTMP server using nginx - A somewhat advanced guide for Linux-based servers

    Read more about this resource...
    Xaymar, devguy and David_V like this.
  2. Zet New Member

    Great guide!
  3. Koolio Member

    Why is there such a lack of easy to use ways of doing this, I have an apache server but I couldn't just wipe it to use ngix even if I wanted to, Though this guide looks like a great help and is exactly want I need.

    I wish you had done a guide on doing it with Red5 as I have another windows server that has Red5 installed, but like you said it is heavy.


    Is there any other free way of doing this same sort of OBS to RTMP relay streaming server setup?
  4. dodgepong Administrator

    Admin

    The only free RTMP servers I know of are Red5, crtmpserver, and nginx with RTMP module. I haven't used Red5 at all, but it seemed more complicated to me than the other two. nginx was the least complicated.

    It's a hard problem in a new field. We're pioneers in this new world of streaming, and consumer-level RTMP servers aren't things that are in high enough demand yet for easy solutions to exist.

    What in particular are you trying to do with your RTMP server?
  5. ThoNohT

    Developer

    nginx should be able to work alongside apache just fine. The only conflict I can imagine is them both wanting to listen on the same port. In that case, you will want to change the http module in the config file, change "listen 80" to "listen 8080" or any other currently unused port. This guide doesn't use the http module for rtmp anyway.
  6. Koolio Member

    I figured that wouldnt' be a problem, but the linux machine I have doesn't have the upstream bandwidth where as the windows machine I have access to has datacenter connection

    I just don't know how u can compile this rmtp module for nginx on windows... the developer of the module also has no idea how..

    seems to be much easier if u use linux
  7. steveswl New Member

    Excellent guide dodgepong!

    A free, open-source, relatively simple RTMP server/client solution is something I've sought after for quite a while. I just set it up on an Ubuntu 12.04 virtual machine. Since the guide is using apt-get and therefore deb packages it's more specific to Linux distributions such as Debian, Ubuntu, Linux Mint, etc. I'll try it on CentOS at some point which uses yum and rpm packages instead of apt-get.

    I also got the stream to work with JW Player. I looked at Using RTMP Streaming.

    The JavaScript code was
    Code
    jwplayer("myElement").setup({
        file: "rtmp://<Ubuntu VM server ip>/live/flv:test",
        height: 360,
        width: 640
    });
    I'm serving the html with the player on nginx as well. There is about a 3 second delay when I watch the stream which isn't that bad.

    I'm using VirtualBox with a Windows server as the host OS and Ubuntu as the guest. VirtualBox or VMware might be a solution if it doesn't hinder the performance of your Windows server too much.

    Building nginx on the Win32 platform with Visual C. Trying to build a Linux application from source on Windows requires a lot of steps. Cygwin, MinGW, MSYS, and a bunch of other libraries are usually needed to be able to do it. I've chosen to use virtualization and run Linux software that way.
  8. dodgepong Administrator

    Admin

    Thanks, steveswl! From my experience, I get 3-3.5 seconds of delay with OBS 0.472b and ~1 second of delay with OBS 0.473b Test 11 and later

    Thanks for the bit on JWPlayer, too. I haven't had a need to show an RTMP stream over the web yet, so I hadn't looked into it, but that is certainly useful information to have.

    Good call about setting up Ubuntu on VirtualBox...since RTMP doesn't require much CPU, that might be Koolio's easiest option.
  9. ScardyBob Member

    Awesome guide! I've been looking for a way to incorporate streams from other casters in a Co-Caster -> Me -> Twitch setup. Only question I have is the bandwidth requirements for incorporating like one or two other streams into your own?
  10. dodgepong Administrator

    Admin

    It takes a decent amount. Tonight, I had 2 cameraman streams upload to my server at 2500 kbps (2.5 Mbps), and then I downloaded both of them simultaneously, so the bandwidth cost was doubled with both upload and download). Overall, I burned through over 11 gigs of transfer on my VPS for a 2-hour cast.

    As for bandwidth pipe size, you'll need enough to download at the speed they are uploading, probably with some headroom. It's something you'll need to experiment with.
  11. Koolio Member

    Just set things up with nginx on a different port instead, works great..

    I still hope someone will do a proper guide for red5, even though it really seems like a barely documented pile of junk... is not much free paths to go on for hosting on windows server.

    The idea of virtualbox linux I might try, it did actually cross mind before, I just don't really want to do it that way, this temp setup with nginx on another server will have to do for now but just doesn't have the kind of connection speed for lots of streams.
  12. mrbrain New Member

    Can you please show how to do authentication?

    I know how a little bit doing it with PHP but it doesn't work right, thanks!
  13. WeissJT New Member

    Hi, thanks for the guide!
    I have a problem. I can't connect to the rtmp server even inside a Lan.
    Always shows this error:
    [​IMG]

    All step were followed correctly.
    No errors in the build stage, nginx is working fine in the standard http port and shows the sample webpage. The server doesn't have a firewall configured.
    Tried on Ubuntu and Archlinux.
    And I think this is correctly configured:
    [​IMG]


    Some ideas?
  14. dodgepong Administrator

    Admin

    Did you edit the nginx.conf file correctly? Was nginx running when you edited the conf file?
  15. WeissJT New Member

    Nevermind, was an error inside of my network. Thanks anyways!

    Now it's working just fine!
  16. Nekuikos Member

    I followed this guide for red5 install:
    Be advised!! i later found that installing JDK 64bit screwed up my firefox java.
    http://juankpro.com/wordpress/2011/01/2 ... n-windows/

    Basicly i installed red5 version 1 locally on my gaming computer.
    Fiddled with the RTMP setup ip (red5.properties in conf folder) and presto OBS could stream to my local ip.

    I used flowplayer to playback the stream from the RTMP server...
    Follow the flowplayer guide i found:
    http://www.unibia.com/unibianet/freebsd ... d?page=0,6
    Please note:
    clip url: stream name (Example: livestream) (OBS: path/key name)
    netConnectionUrl: FMS URL (Example: rtmp://<red5-server>/midiDemo)
    These need to fit what you write into the custome broadcast settings in OBS.
  17. squirrelof09 New Member

  18. dodgepong Administrator

    Admin

    Are you hosting your server on a VPS or on your own box somewhere? Might it be a router issue where the port isn't being forwarded?

    Which port did you change in the config? What RTMP URL are you using?
  19. rlex Member

    Just setup it, works perfectly. Nginx 1.4.1 and recent rtmp module ATM.

    My point was to re-stream to two different servers from my dedicated server in Germany.
    As already said, for restreams you should use push directive, something like that:

    (thanks to KristyKoala for helping with twitch RTMP url)
    And make sure to put proper twitch/hashd/etc RTMP server in url.

    And it will be good idea to protect this stream point since it have access to your twitch/etc streams. You can do that inside application { } block, something like this:
    replace IP with your external IP (ie inside LAN, or in WAN if you use dedicated server, will be great if you have static IP from ISP).

    Of course proper way will be setting up authentication with on_connect function, but it requires external web service (ie PHP scripts) and i have not looked into it ATM. Probably later...
  20. dk-info New Member

    Thank you for a great guide dodgepong!
    I have now installed my own local RTMP server. This is a big step for me to finish an internal info-screen project.

    I installed the RTMP on a vitual Ubuntu 12.04 running on a large (fast) HP server.
    I could not install latest nginx (1.4.1) - but 1.2.9 worked.

    With rtmpdump I am now able to se my stream in VLC.
    But it is far from running smooth. :(
    I repeatedly get 2 seconds of stream + 8-10 seconds of pause.

    My final goal is to show my stream in a webbrowser.
    So right now I am trying to set up an internal webserver to show the stream with JW player.
    I have not yet figured out the right setup for the webserver but am working on it.

    Any tips are of course welcome. :o)