Live streaming from mainland China or Southeast Asia to global platforms like Twitch and YouTube involves a fundamental routing problem: your home internet connection exits through congested international routes, causing dropped frames, stream instability, and inconsistent upload speeds. A Hong Kong VPS as an RTMP relay server solves this — you stream once from your home to Hong Kong over a stable CN2 GIA path, and the VPS re-streams to all your platforms simultaneously with reliable, dedicated bandwidth.
This guide sets up an RTMP relay server on a Hong Kong VPS using Nginx-RTMP, enabling simultaneous streaming to Twitch, YouTube, and Bilibili (哔哩哔哩) with low latency for Asia-Pacific viewers.
Why Hong Kong VPS for Streaming?
- Stable upload path — CN2 GIA routing gives mainland China streamers a consistent, low-jitter path out of China to the VPS, reducing dropped frames from unstable residential ISP routes
- Geographic advantage — Hong Kong is well-connected to both Asian CDNs (Bilibili, Douyu, Huya) and global platforms (Twitch Frankfurt ingest, YouTube primary ingest)
- Multi-platform simultaneous streaming — stream once to your VPS; the VPS pushes to all platforms in parallel
- Low latency for Asian viewers — Bilibili and Asian-focused platforms have ingest points near Hong Kong, giving Asian viewers lower latency than streaming from Europe or US
- Transcoding capability — the VPS can transcode your stream to multiple resolutions (1080p/720p/480p) for platforms that don’t transcode automatically
Required VPS Specifications
| Use Case | CPU | RAM | Bandwidth |
|---|---|---|---|
| Relay only (no transcoding) | 1–2 vCPU | 1–2 GB | 10–20 Mbps outbound per platform |
| Relay + single transcode | 4 vCPU | 4 GB | 30–50 Mbps outbound |
| Multi-bitrate transcoding | 8 vCPU | 8 GB | 50–100 Mbps outbound |
For relay-only (no transcoding) — which is sufficient for most streamers — a 2 GB VPS handles the workload comfortably. CPU transcoding requires significantly more compute.
Step 1: Install Nginx with RTMP Module
apt update && apt upgrade -y
apt install -y build-essential libpcre3 libpcre3-dev libssl-dev \
zlib1g zlib1g-dev libnginx-mod-rtmp nginxVerify the RTMP module is available:
nginx -V 2>&1 | grep rtmpIf the package version doesn’t include the RTMP module, build from source:
# Build Nginx with RTMP module from source
apt install -y libpcre3-dev zlib1g-dev libssl-dev
wget http://nginx.org/download/nginx-1.25.3.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/master.tar.gz -O nginx-rtmp-module.tar.gz
tar xzf nginx-1.25.3.tar.gz
tar xzf nginx-rtmp-module.tar.gz
cd nginx-1.25.3
./configure \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib64/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--with-http_ssl_module \
--with-http_v2_module \
--add-module=../nginx-rtmp-module-master
make -j$(nproc)
make installStep 2: Configure Nginx RTMP for Multi-Platform Streaming
Edit /etc/nginx/nginx.conf — add the RTMP block at the end, outside the http {} block:
rtmp {
server {
listen 1935;
chunk_size 4096;
timeout 30s;
application live {
live on;
record off;
# Stream key authentication
on_publish http://127.0.0.1:8080/auth;
# Push to Twitch
push rtmp://live.twitch.tv/app/YOUR_TWITCH_STREAM_KEY;
# Push to YouTube
push rtmp://a.rtmp.youtube.com/live2/YOUR_YOUTUBE_STREAM_KEY;
# Push to Bilibili
push rtmp://live-push.bilivideo.com/live-bvc/YOUR_BILIBILI_RTMP_KEY;
# Push to additional platforms as needed
# push rtmp://sg.pushlive.douyu.com/live/YOUR_DOUYU_KEY;
}
application local {
live on;
record off;
# Local-only stream (no push) for recording or monitoring
}
}
}nginx -t && systemctl reload nginx
# Open RTMP port in firewall
ufw allow 1935/tcpStep 3: Set Up Stream Key Authentication
Without authentication, anyone who finds your RTMP endpoint can push a stream to it. Add a simple authentication layer:
apt install python3-flask -y
cat > /opt/rtmp-auth/auth.py << 'EOF' from flask import Flask, request app = Flask(__name__) VALID_KEYS = {"YOUR_PRIVATE_STREAM_KEY"} @app.route('/auth', methods=['POST']) def auth(): key = request.form.get('name', '') if key in VALID_KEYS: return '', 200 return '', 403 if __name__ == '__main__': app.run(host='127.0.0.1', port=8080) EOF # Run as a systemd service cat > /etc/systemd/system/rtmp-auth.service << 'EOF'
[Unit]
Description=RTMP Auth Service
After=network.target
[Service]
ExecStart=python3 /opt/rtmp-auth/auth.py
Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl enable --now rtmp-authIn Nginx RTMP config, the on_publish callback checks your stream key before allowing the push. Only streams with your private key are accepted.
Step 4: Configure OBS to Stream to Your VPS
In OBS Studio:
- Open Settings → Stream
- Service: Custom…
- Server:
rtmp://YOUR_HK_VPS_IP/live - Stream Key:
YOUR_PRIVATE_STREAM_KEY
Your OBS stream goes to Hong Kong; the VPS distributes to Twitch, YouTube, and Bilibili simultaneously.
Step 5: Add an HLS Stream for Web Playback
Add HLS output to serve your stream directly from your VPS via HTTP — useful for embedding on your own website or providing a backup viewing option:
application live {
live on;
record off;
# HLS output
hls on;
hls_path /var/www/hls;
hls_fragment 2s;
hls_playlist_length 10s;
# Push to platforms...
}mkdir -p /var/www/hls
chown -R www-data:www-data /var/www/hlsAdd to Nginx HTTP block to serve HLS:
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 *;
}Your stream is then playable at https://yourdomain.com/hls/YOUR_STREAM_KEY.m3u8 in any HLS-compatible player.
Step 6: Monitor Stream Health
Add the RTMP statistics endpoint to monitor active streams:
http {
server {
listen 8088;
location /rtmp-stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /usr/share/nginx/html;
}
}
}Access http://YOUR_VPS_IP:8088/rtmp-stat (restrict access with ufw to your IP only) to see active connections, bitrate, and stream health in real time.
Bandwidth Planning
Calculate your monthly bandwidth requirement:
- Typical 1080p60 stream: 6 Mbps upload from OBS to VPS
- VPS outbound to 3 platforms at 6 Mbps each: 18 Mbps
- 4 hours streaming per day × 30 days × 18 Mbps = ~97 GB/month outbound
Most Server.HK VPS plans include generous monthly bandwidth allocations sufficient for regular streaming schedules. Check your plan’s bandwidth allocation and ensure it covers your streaming hours.
Latency Comparison: Direct vs VPS Relay
| Scenario | Dropped Frames | Stream Stability | Asian Viewer Latency |
|---|---|---|---|
| China home → Twitch direct | High (5–15%) | Poor during peak | High (US ingest) |
| China home → HK VPS → Twitch | Very low (<0.1%) | Excellent | Moderate |
| China home → HK VPS → Bilibili | Very low (<0.1%) | Excellent | Low (HK/Asia ingest) |
Conclusion
A Hong Kong VPS as an RTMP relay server solves the live streaming bottleneck for Asia-Pacific content creators — stable upload over CN2 GIA routing eliminates the dropped frames and reconnections that plague direct streaming from mainland China, and simultaneous multi-platform push to Twitch, YouTube, and Bilibili is handled automatically by Nginx-RTMP.
For streamers, the cost is minimal — a 2 GB VPS handles relay-only streaming comfortably — and the improvement in stream quality and stability is immediate and measurable in your OBS statistics.
Start streaming stably: Browse Server.HK Hong Kong VPS plans — a 2 GB plan handles relay streaming; upgrade to 4 GB if you need CPU transcoding.