Hosting Owncast as alternative to Twitch with podman/docker and nginx

Hosting Owncast as alternative to Twitch with podman/docker and nginx

In recent years, streaming platforms like Twitch have become increasingly popular, allowing users to broadcast content to a vast global audience. While Twitch offers a powerful platform, there are situations where streamers may seek an alternative to control their content, avoid platform limitations, or even reduce reliance on third-party services. Owncast, an open-source live streaming platform, offers the perfect solution for those looking to host their own streaming infrastructure.

This guide will walk you through how to host Owncast as an alternative to Twitch using Podman/Docker for containerization and Nginx as a reverse proxy to manage traffic efficiently.

What is Owncast?

Owncast is a self-hosted live streaming server that allows creators to broadcast video content to their own audience. It offers similar features to Twitch, such as live chat, viewer stats, and stream archiving. The key difference, however, is that you control the entire platform, which allows for a more customizable experience. Owncast also supports RTMP streaming, making it compatible with most broadcasting software, including OBS Studio.

Why Choose Owncast Over Twitch?

  1. Control Over Content: You own your content and have full control over your stream, which is free from platform policies and regulations.
  2. Privacy and Security: Your data remains private and is not shared with third-party platforms.
  3. Customizability: Owncast can be tailored to fit specific needs through plugins and API access.
  4. Cost: Once set up, hosting Owncast can be cost-effective compared to subscription fees for platforms like Twitch.
  5. No Advertisements: Viewers can watch without interruptions from ads.

By using Podman or Docker along with Nginx, you can easily deploy and manage your Owncast server in an isolated environment with minimal configuration.

Prerequisites

What’s Free on the Epic Games Store Right Now  

Before we begin, ensure you have the following:

  1. A server (either physical or virtual) running Linux (Ubuntu/Debian/CentOS).
  2. A domain name pointing to your server (optional but recommended).
  3. Podman or Docker installed on your system.
  4. Nginx installed for reverse proxy and SSL configuration.
  5. Basic understanding of Docker/Podman commands and Nginx configuration.

Step 1: Setting Up Podman/Docker

Install Podman

If you’re using Podman (a rootless container tool similar to Docker), install it by following these steps:

# For Ubuntu/Debian
sudo apt update
sudo apt install -y podman

# For CentOS/RHEL
sudo dnf install -y podman

Install Docker

Alternatively, you can use Docker. To install Docker on Ubuntu/Debian:

# For Ubuntu/Debian
sudo apt update
sudo apt install -y docker.io

Step 2: Pull the Owncast Docker Image

With Podman or Docker installed, the next step is to pull the Owncast image. The Owncast team provides a prebuilt Docker image, making deployment straightforward.

# For Podman
podman pull owncast/owncast

# For Docker
docker pull owncast/owncast

This will download the latest Owncast image from Docker Hub.

Step 3: Configure and Run Owncast Container

To start Owncast, you need to run the container with specific environment variables and ports. The following command will run Owncast on port 8080 for the web interface and port 1935 for RTMP streaming.

# For Podman
podman run -d --name owncast -p 8080:8080 -p 1935:1935 -v /path/to/data:/app/data owncast/owncast

# For Docker
docker run -d --name owncast -p 8080:8080 -p 1935:1935 -v /path/to/data:/app/data owncast/owncast

Make sure to replace /path/to/data with the actual path where you want to store your Owncast data (e.g., stream archives, configuration files, and chat logs).

Step 4: Set Up Nginx as a Reverse Proxy

Using Nginx as a reverse proxy will help manage traffic to your Owncast server and improve performance. It can also be used to handle SSL encryption for secure HTTPS access.

Install Nginx

# For Ubuntu/Debian
sudo apt update
sudo apt install -y nginx

# For CentOS/RHEL
sudo yum install -y nginx

Configure Nginx for Owncast

Now, you’ll need to configure Nginx to proxy traffic to your Owncast container. Edit the Nginx configuration file.

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

Add the following configuration to proxy requests to your container:

server {
    listen 80;
    server_name yourdomain.com;  # Replace with your domain

    location / {
        proxy_pass http://localhost:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
    }
}

Enable and Restart Nginx

Enable the new site and restart Nginx to apply the changes:

# Enable the configuration
sudo ln -s /etc/nginx/sites-available/owncast /etc/nginx/sites-enabled/

# Test the Nginx configuration
sudo nginx -t

# Restart Nginx to apply changes
sudo systemctl restart nginx

Step 5: Configure SSL with Let’s Encrypt

If you want to secure your Owncast instance with HTTPS, you can use Let’s Encrypt for a free SSL certificate. You can use Certbot to automatically obtain and configure the certificate.

First, install Certbot:

sudo apt install certbot python3-certbot-nginx

Then, request an SSL certificate for your domain:

sudo certbot --nginx -d yourdomain.com

Follow the prompts to configure SSL. After this step, your Owncast server will be accessible securely via HTTPS.

Step 6: Stream to Owncast

Now that your Owncast server is running, you can configure your broadcasting software (e.g., OBS Studio) to stream to your server.

  • Set the RTMP server URL in OBS to rtmp://yourdomain.com:1935/live.
  • Set the Stream Key in OBS, which can be found in the Owncast admin panel.

Step 7: Accessing Your Owncast Stream

Your stream will now be live and accessible on your domain (e.g., https://yourdomain.com). Viewers can interact with the chat, watch the stream, and access previous recordings, depending on your configuration.

Conclusion

Hosting your own live streaming platform with Owncast offers a significant advantage over relying on services like Twitch, providing you with complete control over your content and infrastructure. By using Podman/Docker for containerization and Nginx for reverse proxy and SSL management, you can create a highly customizable and secure environment for streaming.

With this setup, you’re ready to stream to a global audience, free from the restrictions and commercial distractions of large platforms. Owncast is an excellent solution for streamers who prioritize autonomy, privacy, and flexibility.