Setting up your own live video streaming infrastructure on a Linux VPS or dedicated server provides full control over bitrate, privacy, and latency without third-party platform restrictions. This complete guide walks through configuring an Nginx RTMP + HLS media server on CentOS 7, publishing from OBS Studio / FFmpeg, and embedding the stream in modern web browsers.
nginx-rtmp-module • HLS fragmenting (Apple HTTP Live Streaming) • Broadcaster: OBS / FFmpeg • Player: HTML5 HLS.js
Part 1: Compiling Nginx with RTMP Support (CentOS 7)
Install development packages and compile Nginx with the RTMP module:
yum install gcc-c++ pcre-devel zlib-devel openssl-devel git -y
cd /usr/src
git clone https://github.com/arut/nginx-rtmp-module.git
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar -zxf nginx-1.12.2.tar.gz
cd nginx-1.12.2
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --with-http_ssl_module --with-http_v2_module --add-module=/usr/src/nginx-rtmp-module
make && make install
Part 2: Configuring RTMP and HLS Ingestion
Add the RTMP server block to /etc/nginx/nginx.conf:
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
hls on;
hls_path /var/www/hls;
hls_fragment 3;
hls_playlist_length 60;
# Restrict streaming publishing to your IP:
allow publish 127.0.0.1;
allow publish YOUR.OFFICE.IP;
deny publish all;
}
}
}
Configure HTTP delivery for the HLS .m3u8 playlists and .ts video segments in /etc/nginx/conf.d/stream.conf:
server {
listen 80;
server_name stream.example.com;
location /hls {
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /var/www;
add_header Cache-Control no-cache;
add_header Access-Control-Allow-Origin *;
}
}
Part 3: Broadcasting and Playback
In OBS Studio, set the Stream URL to rtmp://YOUR-SERVER-IP/live and choose a Stream Key (e.g. mystream). In your web page, point your HLS video player to http://YOUR-SERVER-IP/hls/mystream.m3u8 for instant, cross-browser live playback.