Setting Up a Private RTMP Ingest Server on Your VPS

Published on

How to build your own RTMP streaming relay server using Nginx. Covers installation, multi-platform restreaming, authentication, and recording capabilities.

Written by Jochem, Infrastructure Expert, 5-10 years experience in game server hosting, VPS infrastructure, and 24/7 streaming solutions. Read author bio →

An RTMP ingest server is the backbone of professional streaming infrastructure. Instead of sending your stream directly to Twitch, you send it to your own server, which then distributes it to multiple platforms.

RTMP streaming server infrastructure

Why Run Your Own RTMP Server?

FeatureDirect to TwitchOwn RTMP Server
Multi-platformNo (or paid service)Yes, unlimited
RecordingTwitch VOD onlyFull quality local
Custom processingNoneFFmpeg pipeline
RedundancySingle point of failureAutomatic failover
StatisticsPlatform-dependentFull access

Installation

On Ubuntu/Debian VPS:

apt update
apt install build-essential libpcre3 libpcre3-dev libssl-dev zlib1g-dev

Download and compile Nginx with the RTMP module:

wget http://nginx.org/download/nginx-1.24.0.tar.gz
git clone https://github.com/arut/nginx-rtmp-module.git
tar xzf nginx-1.24.0.tar.gz
cd nginx-1.24.0
./configure --add-module=../nginx-rtmp-module --with-http_ssl_module
make && make install

Configuration

Basic RTMP Relay

rtmp {
    server {
        listen 1935;
        chunk_size 4096;
        
        application live {
            live on;
            record off;
            
            # Push to Twitch
            push rtmp://live.twitch.tv/app/YOUR_TWITCH_KEY;
            
            # Push to YouTube
            push rtmp://a.rtmp.youtube.com/live2/YOUR_YOUTUBE_KEY;
            
            # Push to Kick
            push rtmp://fa723fc1b171.global-contribute.live-video.net/app/YOUR_KICK_KEY;
        }
    }
}

With Authentication

Prevent unauthorized streaming to your server:

application live {
    live on;
    
    on_publish http://localhost:8080/auth;
    
    push rtmp://live.twitch.tv/app/TWITCH_KEY;
}

Create a simple auth endpoint:

from flask import Flask, request

app = Flask(__name__)
VALID_KEY = "your_secret_streaming_key"

@app.route('/auth', methods=['POST'])
def auth():
    key = request.form.get('name')
    if key == VALID_KEY:
        return '', 200
    return '', 403

app.run(port=8080)

With Recording

Save a local copy of every stream:

application live {
    live on;
    
    record all;
    record_path /home/recordings;
    record_unique on;
    record_suffix -%Y%m%d-%H%M%S.flv;
    
    push rtmp://live.twitch.tv/app/TWITCH_KEY;
}

OBS Configuration

In OBS, set your streaming output to your VPS:

Server: rtmp://your-vps-ip/live
Stream Key: your_secret_streaming_key

Everything else (bitrate, encoder, resolution) stays the same as direct streaming.

Advanced: Transcoding

Re-encode the stream on the VPS for different quality levels:

application live {
    live on;
    
    exec_push ffmpeg -i rtmp://localhost/live/$name
        -c:v libx264 -preset veryfast -b:v 3000k -s 1280x720
        -c:a aac -b:a 128k
        -f flv rtmp://localhost/lowres/$name;
}

application lowres {
    live on;
    push rtmp://live.twitch.tv/app/TWITCH_KEY;
}

This ingests your high-quality stream and re-encodes a 720p version for platforms with lower quality requirements.

Monitoring

Add an RTMP statistics page:

http {
    server {
        listen 8080;
        
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }
    }
}

Access http://your-vps-ip:8080/stat to see active streams, bitrates, client connections, and uptime.

VPS Sizing

Use CaseCPURAMBandwidth
Simple relay (no re-encoding)1 core1GBBased on bitrate
Relay + recording2 cores2GBBased on bitrate
Relay + transcoding (720p)4 cores4GB2x bitrate
Relay + transcoding (1080p)6 cores4GB3x bitrate

Simple relaying (no re-encoding) uses almost no CPU. A 1-core VPS can relay a 6Mbps stream to 3 platforms without breaking a sweat.

Your own RTMP server is the foundation of professional streaming infrastructure. Once it's running on a Space-Node VPS, you own your streaming pipeline instead of depending on third-party restreaming services.

Jochem

About the Author

Jochem, Infrastructure Expert, expert in game server hosting, VPS infrastructure, and 24/7 streaming solutions with 5-10 years experience.

Since 2023
500+ servers hosted
4.8/5 avg rating

I specialize in Minecraft, FiveM, Rust, and 24/7 streaming infrastructure, operating enterprise-grade AMD Ryzen 9 hardware in Netherlands datacenters.

View my full bio and credentials →

Start Streaming in Minutes

Join content creators worldwide who trust our streaming infrastructure. Setup is instant and support is always available.

Setting Up a Private RTMP Ingest Server on Your VPS