
Sanjay Sikdar

Create Live Streaming (RTMP) Server on Ubuntu 24.04
In this guide, we will set up an Ubuntu 24.04 server to receive input from Open Broadcaster Software (OBS) and output it in HTTP Live Streaming (HLS) format. Additionally, we will integrate AWS CloudFront for content delivery (CDN) and assign sub-domains for seamless streaming.
For example:
RTMP Link (Input): rtmp://live-in.example.com/live/stream
Stream Key: stream
HLS (Output): https://live.example.com/hls/stream.m3u8
After launching your instance, we need to log in into our new server using SSH client.
ssh -i "YourKey.pem" ubuntu@SERVER_IPAfter login, you need to update packages
sudo apt update && sudo apt upgrade -ySet Timezone (Asia/Kolkata):
sudo timedatectl set-timezone Asia/Kolkata && sudo timedatectlsudo apt install -y ca-certificates curl gnupgsudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo tee /etc/apt/keyrings/docker.asc > /dev/null
sudo chmod a+r /etc/apt/keyrings/docker.ascecho "deb [signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullsudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginsudo systemctl enable --now docker
sudo docker --versionsudo (Optional)sudo usermod -aG docker $USER
newgrp dockerdocker run hello-worldnginx-live-stream Docker ImageTo start the Nginx Live Stream server, follow the steps below:
docker pull sannjayy/nginx-live-stream:latestFor more information about the Docker image, click here.
# Run in CLI
docker run -p 1935:1935 -p 8080:8080 sannjayy/nginx-live-stream
# Run in Detached Mode
docker run -d -p 1935:1935 -p 8080:8080 sannjayy/nginx-live-stream:latestTo start streaming using ffmpeg, execute the command below:
ffmpeg -re -i video.mp4 -c:v libx264 -preset veryfast -maxrate 3000k -bufsize 6000k -pix_fmt yuv420p -g 50 -c:a aac -b:a 160k -ar 44100 -f flv rtmp://SERVER-IP:1935/live/testRename the video.mp4 and replace SERVER-IP with your server's IP address.
To access the embedded player, navigate to the following URL in your browser:
http://SERVER-IP:8080/player/?url=http://SERVER-IP:8080/hls/test.m3u8Origin domain
Public IPv4 DNS of the EC2 InstanceProtocol
HTTP Only
8080
Enable Origin Shield
Compress objects automatically
Viewer protocol policy
Allowed HTTP methods
Restrict viewer access
Legacy cache settings
Headers: None
Query strings: None
Cookies: None
Object caching
Customize
Minimum TTL: 0
Maximum TTL: 0
Default TTL: 0
Your setup is now complete. You have successfully configured an Ubuntu 24.04 server to receive input from Open Broadcaster Software (OBS) and output it in HTTP Live Streaming (HLS) format. Additionally, you have integrated AWS CloudFront for content delivery (CDN) and assigned sub-domains for seamless streaming.
In your DNS Server (Route 53 or Cloudflare) add these records.
| Record Name | Record Type | Value |
|---|---|---|
| live-in | A | [Server_IP] |
| live | CNAME | d1234abcd.cloudfront.net |
Your custom domain setup is now complete. You can access your streaming server using your custom domain (e.g., https://live.example.com/hls/stream.m3u8).
To test the stream: https://sanjaysikdar.dev/tools/video-stream-tester
Before starting, ensure that the following inbound rules are allowed in your firewall settings:
Custom TCP 8080
Custom TCP 1935
TCP 22 for SSH access