Nov 4, 2024 3 min read

Streama: Self-Hosting Made Simple

Streama: Self-Hosting Made Simple
Table of Contents

Streama is an open-source, self-hosted media streaming platform that enables users to create their own Netflix-like server for managing and streaming videos. It’s an excellent choice for tech-savvy users who value data control, customization, and privacy when sharing media files with friends or family. In this guide, we’ll walk you through installing, configuring, and managing Streama, covering everything from deployment to backups and advanced features.

Installing Streama

πŸ“¦ Docker/Docker Compose Setup

Docker simplifies deployment by packaging Streama and its dependencies into an isolated container. Follow these steps to set up Streama with Docker Compose:

  1. Create a docker-compose.yml file for Streama:

version: "3.9"

services:

streama:

image: ghcr.io/dularion/streama:latest

container_name: streama

ports:

- "8080:8080"

volumes:

- ./data:/app/data

- ./logs:/app/logs

environment:

SPRING_PROFILES_ACTIVE: production

SERVER_PORT: 8080

This configuration maps the app’s data and logs to your host filesystem for persistence and sets the app to run in production mode.

  1. Deploy the containers with Docker Compose:

docker-compose up -d

This command will download the Streama image, create the container, and start the service.

  1. Verify that the Streama service is running:

docker ps | grep streama

Open your browser and navigate to http://<server-ip>:8080 to access the Streama UI.

πŸš€ Manual Installation

For those who prefer not to use Docker, a manual installation on Linux is also possible:

  1. Install Java and other dependencies:

sudo apt update

sudo apt install openjdk-11-jre wget unzip -y

  1. Download and extract the latest Streama release:

wget https://github.com/streamaserver/streama/releases/latest/download/streama-*.jar -O streama.jar

  1. Run Streama:

java -jar streama.jar

By default, the application listens on port 8080. You can customize the port using the --server.port=<port> flag.

Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

To expose Streama over the web with a custom domain, configure Nginx as a reverse proxy. Start by creating an Nginx configuration file:


server {

listen 80;

server_name streama.example.com;

location / {

proxy_pass http://127.0.0.1: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;

}

}

Save this file as /etc/nginx/sites-available/streama and symlink it:


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

sudo nginx -t && sudo systemctl reload nginx

πŸ”’ SSL/TLS Setup

Secure your domain with Let’s Encrypt:


sudo apt install certbot python3-certbot-nginx -y

sudo certbot --nginx -d streama.example.com

Certificates will automatically renew via a systemd timer installed with Certbot.

πŸ› οΈ Testing and Reloading Nginx

Verify Nginx configuration and reload the service:


sudo nginx -t

sudo systemctl reload nginx

Access your encrypted Streama instance at https://streama.example.com.

Logging and Debugging Streama

πŸ—ƒοΈ Enabling Debug Logs

To enable verbose logging, set the logging.level configuration in the application’s settings:


java -Dlogging.level.root=DEBUG -jar streama.jar

πŸ“„ Viewing Logs

For Docker users:


docker logs -f streama

For manual installations:


tail -f logs/streama.log

πŸ› οΈ Troubleshooting Common Issues

  • Port not accessible: Ensure the port is open with sudo ufw allow 8080.

  • Nginx misconfiguration: Check the proxy settings in /etc/nginx/sites-available/streama.

πŸ“€ Exporting Logs

Stream Streama logs to an external system like ELK by forwarding the logs:


docker logs streama 2>&1 | curl -XPOST "http://elk-server:9200/streama-logs/_doc" -H "Content-Type: application/json" -d @-

Backup and Restore

πŸ—‚οΈ File-Based Backups

Backup Streama data and logs:


tar -czvf streama-backup.tar.gz data logs

πŸ”„ Database Backups

If Streama uses an external database like PostgreSQL:


pg_dump -U streama_user streama_db > streama_db_backup.sql

πŸ“… Automated Backup Scripts

Add the following cron job to automate backups:


0 2 * * * tar -czvf /backup/streama-$(date +\%F).tar.gz /path/to/data /path/to/logs

Updating and Upgrading Streama

⬆️ Updating Docker Images

Update to the latest image:


docker-compose pull

docker-compose up -d

πŸ› οΈ Manual Updates

Replace the old streama.jar with the latest version:


wget https://github.com/streamaserver/streama/releases/latest/download/streama-*.jar -O streama.jar

java -jar streama.jar

πŸ” Checking for Updates

Monitor the Streama GitHub Releases page for new versions.

Leveraging Streama’s Unique Features

πŸ”§ Enabling APIs

Streama supports RESTful APIs for external integrations. Enable the API in the configuration:


java -Dstreama.api.enabled=true -jar streama.jar

Example API request to retrieve media details:


curl -X GET http://streama.example.com/api/media -H "Authorization: Bearer <API_TOKEN>"

🌟 Advanced Configurations

  • Configure email notifications:

email.host=smtp.example.com

email.port=587

[email protected]

email.password=your-email-password

Wrapping Up

With Streama, you have full control over your media streaming experience, from installation to advanced configurations. By leveraging the code examples provided in this guide, you’ll be able to deploy, secure, and manage your own media server with ease. Start streaming today and enjoy the flexibility and privacy of self-hosting!

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.