Nov 4, 2024 4 min read

Owncast: Self-Hosting Made Simple

Owncast: Self-Hosting Made Simple
Table of Contents

Owncast is a self-hosted, open-source live streaming platform designed to give users complete control over their streams, audience data, and customization. It’s an excellent choice for developers, system administrators, and tech-savvy users who value privacy and independence from centralized platforms. In this guide, we’ll walk through installing Owncast, configuring it with a reverse proxy, enabling logging, setting up backups, keeping it updated, and leveraging its unique features.

Installing Owncast

πŸ“¦ Docker/Docker Compose Setup

Using Docker simplifies the process of deploying Owncast by containerizing it with all its dependencies. Below is a docker-compose.yml file tailored for Owncast. Save this file in a directory of your choice and then run the associated commands.


version: "3.8"

services:

owncast:

image: gabekangas/owncast:latest

container_name: owncast

ports:

- "8080:8080"  # Expose the Owncast web interface and API

volumes:

- ./config:/app/data  # Persist configuration and data

environment:

- OWNCLOUD_LOGLEVEL=debug

restart: unless-stopped

Deploy the container using the following commands:


mkdir owncast && cd owncast

## Save the docker-compose.yml file here, then deploy it

docker-compose up -d

## Verify the container is running

docker ps

πŸš€ Manual Installation

If you prefer a more traditional setup, you can install Owncast directly on a Linux server. Here are the steps:


## Update the package list and install dependencies

sudo apt update && sudo apt install -y wget unzip

## Download the latest Owncast binary from the official GitHub releases

wget https://github.com/owncast/owncast/releases/latest/download/owncast-linux-x64.zip

## Extract the files and move them to a dedicated directory

unzip owncast-linux-x64.zip

sudo mv owncast /opt/owncast

## Make the binary executable

sudo chmod +x /opt/owncast/owncast

## Run Owncast to verify installation

cd /opt/owncast && ./owncast

Owncast will now be accessible on http://<your_server_ip>:8080.

Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

To serve Owncast behind a reverse proxy, create an Nginx server block. This lets you use a custom domain and streamline traffic routing.


server {

server_name yourdomain.com;

location / {

proxy_pass http://127.0.0.1:8080;  # Forward requests to Owncast

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";

proxy_set_header Host $host;

}

error_log /var/log/nginx/owncast.error.log;

access_log /var/log/nginx/owncast.access.log;

}

Save this file in /etc/nginx/sites-available/owncast and enable it:


sudo ln -s /etc/nginx/sites-available/owncast /etc/nginx/sites-enabled/

sudo nginx -t  # Validate the configuration

sudo systemctl reload nginx

πŸ”’ SSL/TLS Setup

Secure your Owncast instance with Let's Encrypt SSL certificates using Certbot:


sudo apt install -y certbot python3-certbot-nginx

## Obtain and apply the certificate

sudo certbot --nginx -d yourdomain.com

## Verify auto-renewal

sudo certbot renew --dry-run

πŸ› οΈ Testing and Reloading Nginx

After applying the configuration, test everything with:


## Check the status of Nginx

sudo systemctl status nginx

## Reload the server to apply changes

sudo systemctl reload nginx

Visit https://yourdomain.com to confirm the setup.

Logging and Debugging Owncast

πŸ—ƒοΈ Enabling Debug Logs

Enable debug-level logging in Owncast for detailed information:


## Open the Owncast configuration file

nano /opt/owncast/config.json

## Set the log level to "debug"

{

"logLevel": "debug"

}

Restart Owncast to apply changes.

πŸ“„ Viewing Logs

Access logs directly from Docker or the filesystem:


## For Docker setup

docker logs -f owncast

## For manual setup

tail -f /opt/owncast/logs/owncast.log

πŸ› οΈ Troubleshooting Common Issues

If Owncast fails to start, check for common issues in the logs such as missing dependencies, port conflicts, or configuration errors.

πŸ“€ Exporting Logs

To send logs to an ELK Stack for analysis, use Filebeat to ship logs from /opt/owncast/logs/owncast.log. Install Filebeat and configure it as needed.

Backup and Restore

πŸ—‚οΈ File-Based Backups

Back up Owncast’s configuration and data:


tar -czvf owncast-backup.tar.gz /opt/owncast/data /opt/owncast/config.json

Restore with:


tar -xzvf owncast-backup.tar.gz -C /opt/owncast

πŸ”„ Database Backups

Owncast doesn’t use a traditional database, but you should back up the data directory as it contains all essential data.

πŸ“… Automated Backup Scripts

Set up a cron job to automate backups:


echo "0 2 * * * tar -czvf /backup/owncast-$(date +\%F).tar.gz /opt/owncast" | sudo tee -a /etc/crontab

Updating and Upgrading Owncast

⬆️ Updating Docker Images

Keep your container up-to-date:


docker pull gabekangas/owncast:latest

docker-compose down

docker-compose up -d

πŸ› οΈ Manual Updates

For manual installations:


## Download the latest release

wget https://github.com/owncast/owncast/releases/latest/download/owncast-linux-x64.zip

## Replace old binaries with the new version

unzip -o owncast-linux-x64.zip -d /opt/owncast

Restart Owncast to apply updates.

πŸ” Checking for Updates

Monitor updates at Owncast GitHub Releases.

Leveraging Owncast’s Unique Features

πŸ”§ Enabling APIs

Enable Owncast’s API in the configuration file:


nano /opt/owncast/config.json

## Add or modify the API settings

{

"api": {

"enabled": true,

"accessToken": "your-secret-token"

}

}

Access the API with a simple curl command:


curl -H "Authorization: Bearer your-secret-token" http://yourdomain.com/api/status

🌟 Advanced Configurations

Customize your stream by editing config.json. For example, you can set a custom stream key:


{

"streamKey": "my-super-secret-key"

}

Reload Owncast to apply changes.

Wrapping Up

With Owncast, you have the power to self-host a fully functional and customizable live streaming platform. From deploying via Docker to securing with Nginx, enabling APIs, and setting up backups, this guide covered everything you need to get started. Now it’s time to put these steps into practice and unlock the full potential of your self-hosted Owncast server!

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Selfhosted Ninja.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.