Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Set Up an Nginx RTMP Streaming Server on Ubuntu

Install Nginx with the RTMP module and receive a live video stream from OBS or a camera.

VPS and Cloud Servers2 min read4 steps4 screenshots

RTMP (Real-Time Messaging Protocol) is used to send live video to a server. The Nginx RTMP module turns Nginx into a streaming server that can receive streams and pass them on.

What you need

  1. An Ubuntu server with root or sudo access.
  2. Basic knowledge of the Linux command line.
  3. A domain name (optional) for outside access.
  4. A video source such as OBS Studio or a camera.

Step 1: Update the system

sudo apt update && sudo apt upgrade -y
Updating Ubuntu

Step 2: Install Nginx and the RTMP module

sudo apt install nginx libnginx-mod-rtmp -y
Installing Nginx and the RTMP module

Step 3: Configure RTMP

Open the main config file:

sudo nano /etc/nginx/nginx.conf

Add this block at the end of the file, outside the http { ... } block:

rtmp {
    server {
        listen 1935;
        chunk_size 4096;

        application live {
            live on;
            record off;
        }
    }
}
The RTMP configuration
  • listen 1935 is the default RTMP port.
  • chunk_size 4096 is the size of the data pieces.
  • application live creates an application named "live".
  • live on allows live streaming.
  • record off does not save the stream to disk.

Test the file and restart Nginx:

sudo nginx -t
sudo systemctl restart nginx

Step 4: Check Nginx

sudo systemctl status nginx
The Nginx service status

Step 5: Open the firewall

sudo ufw allow 1935/tcp

Step 6: Send a stream

In OBS Studio go to Settings > Stream:

  • Service: Custom
  • Server: rtmp://your-server-ip/live
  • Stream key: any name, for example mystream

Click Start Streaming.

Step 7: Watch the stream

In VLC, choose Media > Open Network Stream and enter:

rtmp://your-server-ip/live/mystream

Optional settings

Restrict who can publish (only your IP) inside the application block:

allow publish 203.0.113.10;
deny publish all;

Record streams to files:

record all;
record_path /var/www/recordings;

For playback in web browsers, add HLS output (hls on; hls_path /var/www/hls;) and serve that folder with Nginx.

Quick recap

  • Install nginx and libnginx-mod-rtmp, add the rtmp {} block and open port 1935.
  • Stream to rtmp://server/live/key.