How to set up your own private RTMP server using nginx

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


Nginx-RTMP is an open-source extension module for the Nginx web server that can be used as a media streaming server for both live streams and video on demand using RTMP. This doesn’t come pre-packaged for the operating system, so we’ll need to build Nginx with this module from source code. The first thing we need to do is get some bits. To do so, enter the following:
sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev unzip
This will take some time. Once these are installed we then need to grab the nginx source code. Version 1.8.1 is the latest stable version so we will use that one:
mkdir nginx
cd nginx
tar -zxvf nginx-1.8.1.tar.gz
The next thing we will need is the source for Nginx-RTMP:
At this point, we should have a directory named nginx-1.8.1 which contains the Nginx source code, and one named nginx-rtmp-module-master which contains the Nginx-RTMP source code. The next step is to reconfigure the Nginx source to compile with the Nginx-RTMP module:
cd nginx-1.8.1
./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master
You should see a scroll of text while it is configured, after which you can make and install nginx:
sudo make install
At this point Nginx will be installed into the /usr/local/nginx directory. To test everything is working let’s fire Nginx up:
sudo /usr/local/nginx/sbin/nginx
If everything is working as expected, you should now get the Nginx test page if you navigate to your server’s IP address in a web browser. To stop Nginx you need to call the program again and give it the stop command:
sudo /usr/local/nginx/sbin/nginx -s stop
Now you will need to add the code to configure the RTMP module. This is done in the default config file which is stored with the other files. I’m going to use nano here, but other text editors are available:
sudo nano /usr/local/nginx/conf/nginx.conf
Go to the end of the file and paste in the following configuration:
rtmp {
server {
listen 1935;
chunk_size 8192;
application vod {
play /usr/local/nginx/rtmp;
Save and exit the file. In this file, we’ve told Nginx to listen on port 1935 for RTMP, which is the default port. We’ve also set it to use a chunk size in transfers of 8192 bits. Next, we’ve created an “application” called vod for video on demand. You can have as many of these as you wish, and name them anything you like. We’ve then told it that the vod application will play files from /usr/local/nginx/rtmp directory. This directory doesn’t actually exist yet, so you will need to create it and place some media into it. Note that Nginx-RTMP can only serve flash flv video and mp4 video.
sudo mkdir /usr/local/nginx/rtmp
The next thing to do is start Nginx again, at which point everything is configured and ready for use:
sudo /usr/local/nginx/sbin/nginx
To test you just need to open a stream from your server. The easiest method is to use VLC media player. To open this, go to the “Media” menu and then select “Open Network Stream”. A window will open for you where you can enter the URL for your media.
The URL will start with rtmp:// to tell VLC the protocol to use, and then the domain name or IP address of your server. Next will be a slash, then your application name, in our case “vod”, another slash and finally the filename of the file. So as an example:
This will have more control over your live streaming platform like twitch on iOS, Windows, Linux etc.
So there you have it – a simple streaming server using RTMP based on open source components. Happy streaming!
Just as an FYI the rtmp module for nginx is in the repos now. You don't have to compile from source anymore.You just have to look ;). That reminds me I should get back on my distro that I have abandoned over the years.


New Member
Hi guys, thanks for the procedure. I've tried in under wsl (Ubuntu running on Windows 10). I managed to run the procedure without error, but i'm not able to stream it from VLC.
Is there an up-to-date procedure ?Thanks


New Member
Could you update your Tutorial. We need "unzip" and "zlib1g" "zlib1g-dev" as well in the apt-get install step.

apt-get install unzip build-essential libpcre3 libpcre3-dev libssl-dev zlib1g zlib1g-dev


New Member
I use obs to stream youtube using obs-multi to play FB but obs-multi broadcast to FB only 48 minutes, please guide me how to adjust

Mark Weiss

It's been three years since I unsuccessfully tried streaming through nginx. I spent hundreds of hours trying to get it to work in 2018 and finally had to move on to other things.
However, yesterday, I found a video by Doug Johnson on Youtube "Setup Your Own RTMP + Web Streaming Video Server", where he provides step by step instructions and a custom config for nginx to set it up for RTMP streaming. So I thought, great, a turnkey solution that will work.
Only it didn't. At first, I could not get nginx to run on Windows 10. It kept complaining it couldn't open this log or that config file, even though all were in exactly the places that the Doug Johnson video demonstrated. Eventually, I somehow hacked my way pas that and got nginx running (though it's invisible in task manager) because I could stream to it and get a 'green' status indicator in OBS. And.. the /hls folder was seeing Stream1.ts files appearing every few seconds, so the fragments are being produced. Oddly the thumbnails are all black and don't represent what is in the streamed video.
But the main problem is that when I open the Viewer.html file, all I get is the js player, but no video. I've checked again and again to make sure all paths were matching the config file and they are. It just won't play the video.

hls on;
hls_path /nginx/srv/hls/;
hls_fragment 3;
hls_playlist_length 60;

I'm so close, but still stuck on the last step. It all went without a hitch in Doug's video and I followed his instructions to the tee, but it's not working here. I don't know what the problem is.

Mark Weiss

It looks like nginx is running, but I cannot find it in Task manager.


OBS is streaming to it on "rtmp://" with a healthy status.

The Viewer.html produces this result:

Mark Weiss

If I run the Start.bat as administrator, I see that Windows cannot find nginx.exe. This works on Doug's system, but not my vanilla 'out of the box' Win 10 system.

Batch contents:

@Echo Off
nginx.exe -s quit
start nginx.exe

Result when started as admin:


Mark Weiss

Finally got nginx to run (as verified by Task Manager),

I have OBS streaming, the HLS folder on the server is filling up with 3.35MB video "fragments", and the ports are open on the router, and config of nginx is setup to run 8080 (due to IIS running). Still, the player, both locally, and online do not show the video I am streaming.

Here is my player application embedded in a test website.

The video fragments in the HLS folder all have black thumbnails?
The player doesn't show video. Neither does the locally opened player on the server.
Everything is set up to the letter of Doug Johnson's instructions in his youtube video on how to do this.
The only thing I can think of is some incompatibility between Windows 21H2 and nginx or the java app.


New Member
I wrote a little program that will help ease the creation of the config file for Windows. You will need to provide your own copy of Nginx with RTMP for it to work properly.
Main Window

Config Window (Example)

nginx.conf with settings from previous window.

The ingest will allow for up to 5 applications for other people to stream TO so they can be mixed with OBS on the RTMP server and then rebroadcast out from the Stream application. You can use this with another person to produce multicam streams.

I think its operation is fairly straight forward.
Any feedback is appreciated.!Ar4s89ZajRLcocVjj_y0D_NZVYLmew?e=pM1yRB
I tried using your Nginx but it gives me an error please help
Ảnh chụp màn hình 2021-12-23 072407.png