technology and webhosting news
Use strong credentials on all users, including root and your hosting accounts. Also, install a secure sockets layer (SSL) certificate to encrypt the connection between your server and clients, enabling secure video streaming.
Since users connect to the caching server, CDN reduces the load on your VPS. A video streaming server requires this feature since distributing the data stream continuously to multiple devices might cause instability.

sudo nano /etc/nginx/nginx.conf

su your-username


sudo nginx -s reload

5. Set Up a CDN

Now, connect OBS with your RTMP server by navigating to Settings Stream. From the Service drop-down menu, select Custom. In the Server field, enter the following address:

A private video streaming server cost varies depending on your VPS hosting provider. For example, you can set one up at Hostinger starting at .99/month. Also, consider other services’ prices, like CDN and domain subscriptions.

Once you familiarize yourself with Linux commands, read on to learn how to set up your own server for streaming video in eight steps.

How to Build a Video Streaming Server

The RTMP module directives’ GitHub page lists other parameters for changing your RTMP settings. For example, add the following into server{} to allow only a specific IP address to stream on your server and deny others:

1. Purchase a Virtual Private Server

To choose a VPS for streaming, ensure it provides sufficient bandwidth and computing power to ensure stable performance. Also, it must be compatible with NGINX to enable the RTMP module and offer full root access to avoid permission issues when setting up the software.

echo “0 0,12 * * * root /opt/certbot/bin/python -c ‘import random; import time; time.sleep(random.random() * 3600)’ && sudo certbot renew -q” | sudo tee -a /etc/crontab > /dev/null

Access the HLS stream via http://your_domain:9000/hls/stream.m3u8. Meanwhile, use http://your_domain:9000/dash/stream.mdp to view the DASH broadcast. Note that you might need to embed the URL into HTML to allow web browsers to display them.

sudo apt update

sudo apt upgrade

That’s it! Your video stream is now served via Cloudflare CDN. If you want to learn more about other providers, check out our tutorial on improving website performance when using a content delivery network.

2. Set Up Your VPS

The Stream Key goes at the end of your RTMP stream URL. For example, if you use test, you will connect to the server using this address:

Now, let’s install the real-time messaging protocol (RTMP) module, which enables the NGINX streaming server to transfer video content to client machines with a low latency.

13min Read

sudo apt install python3 python3-venv libaugeas0

  1. Set up a Python virtual environment by running the following commands:

Another protocol is Dynamic Adaptive Streaming over HTTP (DASH), which is open-source and customizable. It lets you enable adaptive bitrate streaming to maintain optimal video quality over an unstable network.

The easiest way to set up a CDN is by using a service provider like Cloudflare. Before doing so, ensure you have pointed a domain name to your VPS since we will use it for the setup. Then, follow these steps:

You can use another media player to check if the URL works so long as it supports RTMP. If you encounter an error, ensure the URL is correct, especially if you change the application path in the NGINX configuration and use a specific stream key.

Next, configure your stream’s scenes, sources, and audio settings. If you are unfamiliar with the streaming software, check the OBS streaming setup Quick Start guide to learn more about it. Click Start Streaming to broadcast your video.

When choosing a VPS hosting plan, ensure it also offers a high-speed connection and sufficient bandwidth. It is important since video streaming needs consistent and continuous data transfer.

In a live video streaming process, this protocol sends the data packets that your broadcasting software encodes. The user’s machine will then recompile the data to display the requested video.

After adding the RTMP block to the NGINX configuration file, press Ctrl + XYEnter to save the changes. Run the following to validate your settings and detect syntax errors:

To help you get started, this tutorial will explain how to set up a video streaming server on a Ubuntu VPS. You will also learn how to enable other streaming protocols and make the broadcast accessible via web browsers.

To create the configuration file, run the following command. Note that it may have no extension:

A video streaming server is an intermediary system that lets you broadcast content live from your local system to online audiences.
The live streaming process works by encoding video content in real-time, breaking it into smaller data packets, and sending it to the client. The media transfer is continuous, meaning the server doesn’t store the media locally.

A video streaming service like YouTube lets users broadcast content to online audiences. While such a platform is easy to set up, it has limited customization options and policy restrictions.

We recommend using the default value and adjusting it gradually to see if the new setting affects your video server performance. Also, remember that broadcasting content on multiple channels will consume extra resources.

However, DASH is not compatible with some players and web browsers. In addition, it is an obsolete protocol that might be unreliable for long-term use. Similar to HLS, enable DASH by adding the following configurations:

To set up your own video streaming server, you need a VPS running a Linux operating system, like Ubuntu 22.04. It must also be compatible with the NGINX web server since we will utilize its data transmission module.


sudo systemctl enable nginx

To enable HLS, add the following directives to application live {} in your video streaming server configuration file:

Hostinger’s VPS provides a 300 Mb/s connection and up to 32 TB of bandwidth. Our high-performance network ensures your live streaming platform broadcasts videos reliably without buffering.

  • listen 1935 – the port number your RTMP server listens, set to 1935 by default.
  • chunk_size 4069 – the size of video chunks the server will send in bytes, set to 4096 bytes or 4 KB by default.
  • application live – the live streaming application that will be available at the /live URL.
  • live on – the live mode toggle to allow multiple users to connect to your stream simultaneously.
  • record off – the RTMP recording functionality toggle. Setting it to off means the server won’t store streamed video locally.

dash on;

dash_path /var/www/html/tmp/dash;

dash_fragment 15;

Once your streaming server is accessible to online users, apply proper security practices to enable secure data transmission and minimize potential entry points for cybercriminals.

Setting up your own media streaming server also requires basic Linux server administration knowledge. If you are unfamiliar with it, we recommend reading our Linux commands tutorial to learn more about the essential utilities.

  • chunk_size – a large data chunk might cause high latency while setting it to low will cause overhead due to extra transmissions.
  • max_connections – the maximum number of concurrent connections to your RTMP server, which can consume a high video streaming bandwidth if set too high.
  • record – the toggle for recording mode, which will consume extra computing power and storage space when enabled.
  • max_message – the maximum size of input data sent as a message. Setting it too high will consume more memory and might cause server instability.

sudo yum update

sudo yum upgrade

3. Install NGINX and the RTMP Module

sudo apt install -y nginx

Let’s check if your video streams to the server correctly. You can do so by accessing the URL via a media player like VLC. Here are the steps:

Building your own streaming server offers more flexibility and control than using platforms like YouTube and Twitch. For example, you can choose different protocols to encode your video, like RTMP, HLS, or DASH. It also allows you to broadcast any content or use monetization options that such platforms may restrict.

To choose the best streaming software, consider your computer’s operating system, hardware capability, and tool requirements. For this tutorial, we will use OBS as it is free, lightweight, and easy to set up.

allow publish;

deny publish all;

usermod -aG sudo your-username

Based on them, Hostinger is an ideal choice. All our VPS plans have a Browser terminal that lets you connect to the system without an SSH client. It helps simplify the live streaming server setup process since you can do so directly from your web browser.

  1. Open the Cloudflare website. Click Sign Up to create a new account and complete the verification process.
  2. Log in to your Cloudflare dashboard and click Add site on the top right of your screen.
  3. Enter your domain name in the provided field and click Continue to confirm.
  1. Select your preferred plan. We recommend choosing the free one at the bottom since you can upgrade later anytime. Click Continue to proceed.
  2. You will be prompted with the DNS records review page. Ensure all the records point to your domain name and click Continue.
  1. In the next screen, Cloudflare will provide you with nameservers for your domain. Copy and save them in a safe location.

sudo apt install build-essential git libpcre3-dev libssl-dev zlib1g-dev

The steps to set up SSL on your VPS differ depending on the certificate issuer. For this tutorial, we will configure a free plan from Certbot, which offers the same security level as the paid ones. Here are the steps:

cd nginx

./auto/configure –add-module=../nginx-rtmp-module


sudo make install

4. Configure NGINX for Video Streaming

The NGINX web server offers two additional video streaming protocols aside from RTMP, which you can enable via the nginx.conf file.

  • Open broadcaster software (OBS) – an open-source live streaming software with a user-friendly interface and versatile functionalities.
  • Streamlabs – a streaming solution based on OBS with additional features, but more resource-intensive and less reliable.
  • Wirecast – a premium live video broadcaster with built-in editing features and extensive media streaming source support.
  • XSplit – a popular tool with expandable features via plugins, but complicated to configure due to the lack of presets.

Now, return to VLC and try streaming the video to check if the problem is resolved.

hls on;

hls_path /var/www/html/stream/hls;

hls_fragment 15;

Similarly, properly set firewall rules on your VPS to listen only to the necessary ports and close the others. Leaving all of them open will expose your server to additional exploitable entry points for hackers.

SSL masks the transmitted data into indecipherable characters, preventing cyber criminals from obtaining raw personal information like the user’s IP address.

rtmp {

   server {

      listen 1935;

      chunk_size 4096;           

      application live {

         live on;

         record off;




After purchasing and setting up your VPS plan, let’s prepare the hosting environment by updating its repository and installing the video server software.

To install the NGINX RTMP module, run the following command:

Pro Tip

Aris Sentika

7. Test Your Stream

You can also broadcast on-demand video content. However, you must put the video file inside the live streaming server.

  1. Download VLC from the official page and install it on your local computer.
  2. Open the media player, select Media in the top left corner, and click Open Network Stream.
  3. On the Open Media window, select the Network tab.
  4. Paste your RTMP stream URL into the provided field and click Stream to start streaming your video.

Aris is a Content Writer specializing in Linux and WordPress development. He has a passion for networking, front-end web development, and server administration. By combining his IT and writing experience, Aris creates content that helps people easily understand complex technical topics to start their online journey. Follow him on LinkedIn.

Download OBS Studio from the official page and open the installer package. Follow the installation wizard instructions to finish the setup process. Once completed, open the obs64.exe application.

You can add the settings to nginx.conf, but we will use a separate file within /sites-available to organize the code and simplify maintenance. It can also apply settings only to a specific site for isolation.

In addition, our VPS AI Assistant lets you generate commands for installing and setting up the media streaming server software. This makes Hostinger’s VPS plan especially suitable for new VPS users unfamiliar with Linux system administration.

  1. Open hPanel, select VPS, and click Manage on the video streaming server.
  2. From the sidebar, navigate to SettingsSecurityFirewall.
  3. Click Create firewall configuration and enter its name. Click Create.
  4. Click the three-dot icon on the new rule and select Edit.
  5. Add a rule that accepts connection from any source via port 1935, similar to the following.
  1. Click Add rule. Return to the main firewall configuration page and activate your RTMP rule.

Also, check the correct address using an online tool like whatismyipaddress and see if the value matches. After changing the configuration file, remember to always reload NGINX to apply the changes.

8. Secure Your Streaming Server

Once the streaming server is ready, set up video streaming software on your local machine to cast the content. Since there are various options, we will provide several popular tools to help you choose:

In addition, your server must support the SSH connection to execute commands remotely. Your local system must also have an SSH client like PuTTY installed to access the VPS. For Linux and MacOS, use the built-in Terminal.

server {

    listen 9000;

    location / {

        add_header Access-Control-Allow-Origin *;

        root /var/www/html/stream;



types {

    application/dash+xml mpd;


Next, grant the new user the superuser privilege to enable administrative command executions using sudo. You can do so by entering the following:

  1. Connect to your VPS via SSH and switch to a superuser account.
  2. Install the dependencies using the following command. Remember to replace apt according to your system’s package manager:

Important! To avoid issues, test changes on a testing area before applying them to the live environment. After applying new settings, monitor your server to check for instability.

Setting up your own server offers more flexibility and control over third-party video streaming platforms like YouTube. The easiest way to do so is by installing NGINX and the RTMP module in a Linux VPS.

Return to the Cloudflare dashboard and click Check nameservers now. If a message containing your domain name shows up, click Continue. You will be prompted with a Quick Start Guide, but we’ll choose Finish later.

How to Use Other NGINX Streaming Protocols

Moreover, ensure your firewall allows NGINX connection via ports 1935, 80, and 443. You can use Linux’s built-in tools like iptables or Uncomplicated Firewall. Alternatively, use hPanel’s Firewall Configuration feature by following these steps:

sudo mkdir /var/www/html/stream

Also, change the root path based on your protocol path directives. If you haven’t created the folder, make one using the mkdir command like so:

In addition, check whether your configuration file contains settings that permit or block streams from a specific IP address. If so, ensure it puts your VPS and the system that broadcasts the video in the allowlist.

In this section, we will answer several commonly asked questions about how to build a streaming service. If yours remains unanswered, ask it in the comment section below!

Since users are more likely to live stream videos without a dedicated media player like VLC, make your media accessible via web browsers. Before doing so, enable the HLS and DASH protocols since only using RTMP might cause compatibility issues.

sudo apt install -y libnginx-mod-rtmp

sudo git clone

sudo git clone

sudo nano /etc/nginx/sites-available/rtmp

For example, the HTTP Live Streaming (HLS) protocol is ideal for multi-platform streaming due to its compatibility with any web browser and HTML5 video player. However, it’s not suitable for gaming or interactive broadcasting due to a high latency.

If you need the latest version, download NGINX and RTMP directly from their GitHub repositories. Before doing so, install the following dependencies for building the package:

adduser your-username

Don’t close the dashboard since we will use it to check the configuration later. Now, let’s point your domain name to the new nameservers. Here’s how to do so at Hostinger:

sudo nginx -t

sudo systemctl status nginx

Here are several important streaming setup parameters and their impact on performance:

However, we will create another superuser since running commands as root might cause severe issues if not careful. To do so, run the following:

Install NGINX and RTMP from your system repository or their GitHub page if you need the latest release. Then, open nginx.conf and add the RTMP block to set up custom video player configurations.

Start by connecting to your server via SSH using PuTTY or Browser terminal. You can find the login credentials under the SSH access tab in hPanel’s VPS overview menu. By default, you will connect as root.

How to Set up a Video Streaming Server FAQ

Since setting up a streaming server requires a VPS, purchase a plan from a reputable provider if you haven’t already done so. To choose the best VPS hosting for broadcasting video content, consider the prerequisites we explained previously.

Why Build Your Own Live Streaming Server?

Configure Cloudflare CDN to improve your live streaming server stability. Now, install video broadcast software on your local system and enter the RTMP server’s URL. Start streaming and check if the video loads properly using the VLC media player.

How Much Does It Cost to Start Your Own Streaming Service?

If you want complete control, set up your own streaming solutions. The easiest way to do so is using a virtual private server (VPS) hosting plan from a provider like Hostinger, which comes with features that help simplify the configuration process, like a control panel.

What Are the Key Features to Look for in Video Streaming Servers?

In a streaming environment, this caching software stores segments of the broadcasted video in real-time. It will then serve clients content from the temporary data stored in the CDN network instead of the host server.

The author
To create a video streaming server, purchase a VPS hosting plan compatible with both software, like Hostinger’s. Connect to it via SSH and switch from root to another superuser account. Update your system’s repository using the upgrade command.

Apr 15, 2024

Similar Posts