A simple Twitch clone for exploring live streaming with NGINX, RTMP, and HLS. Users can stream via OBS or other software and watch other streams.
- Low-latency streaming
- Stream & user authentication
- Watch other users' live streams
cd client
npm install
npm run dev # Starts the frontend at http://localhost:5173cd ../server
npm install
npm run dev # Starts the backend at http://localhost:5174npm run prisma:migrate:dev # Creates schema to MySQL
npm run prisma:generate:dev # Generates Prisma client (for intellisense)Install NGINX with RTMP Module
sudo apt install nginx libnginx-mod-rtmp -yConfigure NGINX Server
Append the RTMP block from /configs/nginx/nginx.conf to nginx.conf
sudo nano /etc/nginx/nginx.conf # Add RTMP settingsCreate an HTTP configuration for HLS and STAT
cp configs/nginx/echo.conf /etc/nginx/sites-available/echo.confApply changes
systemctl restart nginx- RTMP (Real-Time Messaging Protocol)
- Used by streaming software (e.g., OBS) to send live video to a media server.
- Ensures a stable and low-latency connection between the broadcaster and the server.
- HLS (HTTP Live Streaming)
- Converts the RTMP stream into smaller video segments (.ts files).
- Creates a playlist (.m3u8) that allows adaptive playback on web browsers and mobile devices.
Together, RTMP handles video ingestion, while HLS makes it playable for viewers.
STAT is an RTMP status report that provides real-time information about active streams on the RTMP server. It helps monitor stream activity, including:
- Current live streams
- Bitrate and bandwidth usage
- Connected viewers
- Stream key details
📌 In our setup, it was used to track stream heartbeats. These heartbeats help detect streams that appear LIVE but are no longer active, ensuring they are correctly marked as OFFLINE. To check the RTMP status:
curl http://172.23.238.4:5175/stat📌 This is useful for debugging and monitoring stream performance.
- RTMP URL:
rtmp://172.23.238.4:1935/live - OBS Settings:
- Go to Settings > Stream
- Set Service: Custom
- Enter RTMP URL +
Your Stream Key
- Start Streaming
📌 Watch via HLS: http://172.23.238.4:5175/hls/Your Stream Key/index.m3u8