Instant RTMP streaming server with nginx

Sometimes, you just need a quick live streaming setup with minimum latency and a little bit of privacy. The best way to do this is just to stream directly from your Windows PC to someone else. And setting up your own RTMP server isn't that hard. Here's how:

  1. Download nginx 1.7.11.3 Gryphon from http://nginx-win.ecsds.eu/download/. It has to be this version, because the newer builds aren't compiled with the RTMP module.
  2. Create an nginx.conf in the conf directory with the following content:
daemon off;
worker_processes 2;
events { 
    worker_connections  1024;
}

rtmp {
    server {
        listen 1935;
        chunk_size 4096;

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

http {
    server_tokens off;
    include mime.types;
    charset utf-8;

    access_log logs/access.log  combined;

    server {
        server_name localhost;
        listen 0.0.0.0:80;

        error_page 500 502 503 504 /50x.html;

        location / {
            root html;
        }

        location /stat {
            rtmp_stat all;
        }
    }
}

You should then be able to launch the server and stream to rtmp://localhost/live/test for example. The "test" part can be replaced with anything here. In OBS, you would just set rtmp://localhost/live as the server URL and "test" as the stream key.

The HTTP section is just a simple web server for the html directory, but it also configures some stats to be visible under http://localhost/stat. That's important so you know who is streaming right now.

And that's it! Forward port 1935 and use a player like VLC to watch the stream directly via the RTMP url.