A Hong Kong VPS configured as a live streaming server provides the lowest possible latency origin point for delivering live content to mainland Chinese and Asia-Pacific viewers. With CN2 GIA routing, stream ingest from Chinese streamers achieves sub-30 ms round-trip time, while CDN distribution from the Hong Kong origin reaches global audiences efficiently.
This guide sets up a complete live streaming stack: Nginx with the RTMP module for stream ingest, FFmpeg for multi-quality transcoding, HLS output for broad device compatibility, and integration with Cloudflare or BunnyCDN for global distribution.
Architecture Overview
Streamer (OBS/encoder)
│ RTMP push
▼
Hong Kong VPS (Nginx-RTMP)
│ FFmpeg transcode
▼
HLS segments (1080p / 720p / 480p)
│ CDN pull
▼
Cloudflare / BunnyCDN edge
│ HTTP delivery
▼
Viewers (web, mobile, smart TV)Step 1: Install Nginx with RTMP Module
apt update && apt upgrade -y
apt install -y nginx libnginx-mod-rtmp ffmpegVerify the RTMP module is loaded:
nginx -V 2>&1 | grep rtmpStep 2: Configure Nginx RTMP and HLS
nano /etc/nginx/nginx.confAdd the RTMP block at the end of the file (outside the http {} block):
rtmp {
server {
listen 1935;
chunk_size 4096;
allow publish all;
allow play all;
application live {
live on;
record off;
# Stream key authentication
# on_publish http://127.0.0.1:8080/auth;
# HLS output
hls on;
hls_path /var/www/hls;
hls_fragment 2s;
hls_playlist_length 10s;
hls_cleanup on;
# Multi-quality transcoding via FFmpeg
exec ffmpeg -i rtmp://localhost/live/$name
-c:v libx264 -preset veryfast -tune zerolatency
-c:a aac -ar 44100
# 1080p
-vf scale=-2:1080 -b:v 4500k -maxrate 4500k -bufsize 9000k
-hls_time 2 -hls_list_size 5
-hls_segment_filename /var/www/hls/${name}_1080p_%03d.ts
/var/www/hls/${name}_1080p.m3u8
# 720p
-vf scale=-2:720 -b:v 2500k -maxrate 2500k -bufsize 5000k
-hls_time 2 -hls_list_size 5
-hls_segment_filename /var/www/hls/${name}_720p_%03d.ts
/var/www/hls/${name}_720p.m3u8
# 480p
-vf scale=-2:480 -b:v 1000k -maxrate 1000k -bufsize 2000k
-hls_time 2 -hls_list_size 5
-hls_segment_filename /var/www/hls/${name}_480p_%03d.ts
/var/www/hls/${name}_480p.m3u8 2>>/var/log/ffmpeg-$name.log &
}
}
}Add HLS serving to the HTTP block:
server {
listen 8080;
server_name YOUR_VPS_IP;
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 *;
}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
}Create HLS directory and set permissions
mkdir -p /var/www/hls
chown -R www-data:www-data /var/www/hls
nginx -t && systemctl reload nginxStep 3: Configure OBS Studio for RTMP Push
In OBS Studio → Settings → Stream:
- Service: Custom
- Server:
rtmp://YOUR_VPS_IP/live - Stream Key:
mystream(any name — this becomes the stream identifier)
Start streaming. Your stream will be accessible at:
http://YOUR_VPS_IP:8080/hls/mystream_1080p.m3u8
http://YOUR_VPS_IP:8080/hls/mystream_720p.m3u8
http://YOUR_VPS_IP:8080/hls/mystream_480p.m3u8Step 4: Create an Adaptive Bitrate Master Playlist
Create a master playlist that lets players automatically select the appropriate quality:
cat > /var/www/hls/mystream.m3u8 << 'EOF'
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=4500000,RESOLUTION=1920x1080
mystream_1080p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2500000,RESOLUTION=1280x720
mystream_720p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1000000,RESOLUTION=854x480
mystream_480p.m3u8
EOFThis is better generated dynamically by your application — update it when streams start/stop.
Step 5: Implement Stream Key Authentication
Without authentication, anyone can push a stream to your RTMP server. Add a simple Node.js authentication endpoint:
nano /home/deploy/stream-auth.jsconst http = require('http');
const url = require('url');
const VALID_KEYS = {
'secret_key_channel1': 'channel1',
'secret_key_channel2': 'channel2'
};
const server = http.createServer((req, res) => {
if (req.method === 'POST' && req.url.startsWith('/auth')) {
let body = '';
req.on('data', chunk => body += chunk);
req.on('end', () => {
const params = new URLSearchParams(body);
const key = params.get('name');
if (VALID_KEYS[key]) {
res.writeHead(200);
res.end('OK');
} else {
res.writeHead(401);
res.end('Unauthorized');
}
});
} else {
res.writeHead(404);
res.end();
}
});
server.listen(8080, '127.0.0.1');
console.log('Stream auth server running on port 8080');pm2 start /home/deploy/stream-auth.js --name stream-authUncomment the on_publish line in the Nginx RTMP config and reload Nginx.
Step 6: CDN Integration for Global Distribution
BunnyCDN (recommended for cost)
- Create a Pull Zone in BunnyCDN pointing to
http://YOUR_VPS_IP:8080 - Set cache rules: HLS .ts segments cache for 60 seconds; .m3u8 playlists cache for 2 seconds (or no-cache)
- Point your streaming subdomain (e.g.
stream.yourdomain.com) to the BunnyCDN pull zone hostname
Viewers access: https://stream.yourdomain.com/hls/mystream.m3u8
Cloudflare (free tier)
Add your VPS as the origin, proxy the streaming subdomain through Cloudflare. Configure Page Rules to set Cache Level: Bypass for *.m3u8 files (playlists must not be cached) and Cache Everything for *.ts files (segments can be cached at edge).
Recommended VPS Specs for Streaming
| Concurrent Streams | Quality | Recommended vCPU | RAM | Bandwidth |
|---|---|---|---|---|
| 1–2 | Up to 1080p, 3 qualities | 4 vCPU | 4 GB | 100 Mbps |
| 3–5 | Up to 1080p, 3 qualities | 8 vCPU | 8 GB | 500 Mbps |
| 10+ | Mixed quality | Dedicated server | 16+ GB | 1 Gbps |
FFmpeg transcoding is CPU-intensive — each 1080p → 3-quality transcode job uses approximately 1.5–2 vCPUs continuously. Scale vCPU count with concurrent stream count.
Conclusion
A Hong Kong VPS live streaming server with Nginx-RTMP and FFmpeg transcoding delivers a complete ingest-to-CDN streaming pipeline for content creators and platforms targeting Asian audiences. CN2 GIA routing ensures streamers in mainland China can push their streams with minimal latency, while CDN distribution delivers HLS output globally.
Scale your streaming infrastructure on Server.HK’s Hong Kong VPS and dedicated server plans — high-bandwidth uplinks and NVMe SSD storage optimised for media workloads.
Frequently Asked Questions
What bitrate should I use for live streaming to Chinese mobile users?
Chinese mobile users are predominantly on 4G/5G networks. A 720p stream at 2.5 Mbps provides excellent quality for most mobile viewers. Always offer adaptive bitrate (multiple quality levels) so viewers on slower connections automatically receive the 480p or lower quality stream without buffering.
Can I use OBS with an RTMP server on Hong Kong VPS for streaming to Chinese platforms?
Yes. Your Hong Kong VPS RTMP server can simultaneously re-stream to Chinese platforms (Bilibili, Douyu, Huya) using FFmpeg’s output capabilities. Add RTMP push targets in the exec block to forward the ingest stream to platform RTMP endpoints. This enables a single OBS stream to reach multiple Chinese platforms simultaneously.
How much bandwidth does a live streaming server consume?
A single 1080p/720p/480p multi-quality stream consumes approximately 8 Mbps inbound (from streamer) and 8 Mbps × number of direct viewers outbound. With CDN integration, your VPS bandwidth is primarily the CDN pull bandwidth — typically 1–3 Mbps per CDN PoP pulling segments, regardless of viewer count.