Streaming advanced ⏱ 60 minutes

PeerTube: Federated Video Platform

YouTube alternative with ActivityPub. Host videos with federation support.

By Homelab Team • 2025-01-15
#peertube#video#federation#youtube#docker

PeerTube is a free, decentralized video hosting platform that puts you in control of your content while connecting you to a global federation of independent video platforms. It’s a privacy-respecting, censorship-resistant alternative to centralized platforms like YouTube.

What is PeerTube?

PeerTube is a federated video platform built on ActivityPub, the same protocol powering Mastodon and the broader Fediverse. Instead of relying on a single corporate entity, PeerTube creates a network of independent instances that can share content and audiences while maintaining individual ownership and control.

Why Choose PeerTube?

Decentralization and Federation:

  • Join a network of independent instances
  • Follow creators across different PeerTube servers
  • No single point of failure or censorship
  • Own your instance, own your data

Privacy and Freedom:

  • No algorithmic manipulation
  • No data mining or tracking
  • No arbitrary content restrictions
  • Full control over your platform rules

Advanced Features:

  • WebTorrent/P2P video distribution
  • Live streaming support (RTMP and HLS)
  • Multiple quality transcoding
  • Plugins and customization
  • Federation with Fediverse (Mastodon, etc.)

Cost Effective:

  • No revenue sharing with platform
  • Bandwidth shared via P2P
  • Scale with your community
  • Self-hosted infrastructure

PeerTube vs. Centralized Platforms

FeaturePeerTubeYouTubeVimeo
Monthly Cost$0$0 (ads/revenue share)$0-$75+
Content OwnershipFullLimitedLimited
FederationYesNoNo
PrivacyCompleteMinimalLimited
Monetization Control100% yours45% revenue sharePlatform fees
Algorithmic FeedOptionalForcedLimited
P2P BandwidthIncludedN/AN/A
Live StreamingIncludedRequires subscribersPremium only

Prerequisites

Before starting, ensure you have:

  • Docker and Docker Compose installed
  • At least 4GB RAM (8GB+ recommended)
  • CPU with hardware transcoding (Intel Quick Sync or NVIDIA GPU highly recommended)
  • Storage for videos (starts at 50GB, grows with content)
  • PostgreSQL and Redis (included in Docker setup)
  • Domain name (required for federation)
  • Email server or SMTP credentials (for notifications)
  • Stable internet connection

Understanding PeerTube Architecture

PeerTube consists of several components:

Web Server: Node.js application serving the platform Database: PostgreSQL for metadata and user data Redis: Caching and job queue management Transcoding: FFmpeg with hardware acceleration Storage: Object storage for videos (local or S3-compatible) P2P Distribution: WebTorrent for bandwidth sharing Federation: ActivityPub for cross-instance communication

Directory Structure

Create organized directories for PeerTube:

# Create PeerTube directories
mkdir -p /opt/peertube/{config,data,postgresql,redis}

# Set ownership
sudo chown -R $USER:$USER /opt/peertube

Directory Explanation:

  • /opt/peertube/config: PeerTube configuration files
  • /opt/peertube/data: Video files, thumbnails, torrents
  • /opt/peertube/postgresql: Database storage
  • /opt/peertube/redis: Cache and job queue data

Docker Compose Configuration

Complete Production Setup

Create /opt/peertube/docker-compose.yml:

version: '3.8'

services:
  peertube:
    image: chocobozzz/peertube:production-bookworm
    container_name: peertube
    restart: unless-stopped
    ports:
      - "9000:9000"    # Web interface
      - "1935:1935"    # RTMP for live streaming
    volumes:
      - /opt/peertube/data:/data
      - /opt/peertube/config:/config
    environment:
      - PEERTUBE_DB_USERNAME=peertube
      - PEERTUBE_DB_PASSWORD=peertube_secure_password_change_me
      - PEERTUBE_DB_HOSTNAME=postgres
      - PEERTUBE_REDIS_HOSTNAME=redis
      - PEERTUBE_WEBSERVER_HOSTNAME=peertube.yourdomain.com
      - PEERTUBE_WEBSERVER_PORT=443
      - PEERTUBE_WEBSERVER_HTTPS=true
      - [email protected]
      - PEERTUBE_SMTP_HOSTNAME=smtp.gmail.com
      - PEERTUBE_SMTP_PORT=587
      - [email protected]
      - PEERTUBE_SMTP_USERNAME=your-[email protected]
      - PEERTUBE_SMTP_PASSWORD=your-app-password
      - PEERTUBE_SMTP_TLS=true
    depends_on:
      - postgres
      - redis

  postgres:
    image: postgres:16-alpine
    container_name: peertube-postgres
    restart: unless-stopped
    volumes:
      - /opt/peertube/postgresql:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=peertube
      - POSTGRES_PASSWORD=peertube_secure_password_change_me
      - POSTGRES_DB=peertube

  redis:
    image: redis:7-alpine
    container_name: peertube-redis
    restart: unless-stopped
    volumes:
      - /opt/peertube/redis:/data
    command: redis-server --appendonly yes

Important Configuration Notes:

  • Change all passwords to strong values
  • Set your domain in PEERTUBE_WEBSERVER_HOSTNAME
  • Configure SMTP for email notifications
  • HTTPS is strongly recommended for federation

With Hardware Transcoding (Intel Quick Sync)

Add device mapping for Intel hardware transcoding:

version: '3.8'

services:
  peertube:
    image: chocobozzz/peertube:production-bookworm
    container_name: peertube
    restart: unless-stopped
    ports:
      - "9000:9000"
      - "1935:1935"
    devices:
      - /dev/dri/renderD128:/dev/dri/renderD128
      - /dev/dri/card0:/dev/dri/card0
    group_add:
      - "109"  # render group ID - check with: getent group render
    volumes:
      - /opt/peertube/data:/data
      - /opt/peertube/config:/config
    environment:
      - PEERTUBE_DB_USERNAME=peertube
      - PEERTUBE_DB_PASSWORD=peertube_secure_password_change_me
      - PEERTUBE_DB_HOSTNAME=postgres
      - PEERTUBE_REDIS_HOSTNAME=redis
      - PEERTUBE_WEBSERVER_HOSTNAME=peertube.yourdomain.com
      - PEERTUBE_WEBSERVER_PORT=443
      - PEERTUBE_WEBSERVER_HTTPS=true
      - [email protected]
      - PEERTUBE_TRANSCODING_ENABLED=true
      - PEERTUBE_TRANSCODING_THREADS=4
      - PEERTUBE_TRANSCODING_PROFILE=vod_profile
    depends_on:
      - postgres
      - redis

  postgres:
    image: postgres:16-alpine
    container_name: peertube-postgres
    restart: unless-stopped
    volumes:
      - /opt/peertube/postgresql:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=peertube
      - POSTGRES_PASSWORD=peertube_secure_password_change_me
      - POSTGRES_DB=peertube

  redis:
    image: redis:7-alpine
    container_name: peertube-redis
    restart: unless-stopped
    volumes:
      - /opt/peertube/redis:/data
    command: redis-server --appendonly yes

With NVIDIA GPU Transcoding

For NVIDIA hardware transcoding:

version: '3.8'

services:
  peertube:
    image: chocobozzz/peertube:production-bookworm
    container_name: peertube
    restart: unless-stopped
    runtime: nvidia
    ports:
      - "9000:9000"
      - "1935:1935"
    environment:
      - NVIDIA_VISIBLE_DEVICES=all
      - NVIDIA_DRIVER_CAPABILITIES=compute,video,utility
      - PEERTUBE_DB_USERNAME=peertube
      - PEERTUBE_DB_PASSWORD=peertube_secure_password_change_me
      - PEERTUBE_DB_HOSTNAME=postgres
      - PEERTUBE_REDIS_HOSTNAME=redis
      - PEERTUBE_WEBSERVER_HOSTNAME=peertube.yourdomain.com
      - PEERTUBE_WEBSERVER_PORT=443
      - PEERTUBE_WEBSERVER_HTTPS=true
      - [email protected]
      - PEERTUBE_TRANSCODING_ENABLED=true
      - PEERTUBE_TRANSCODING_THREADS=0
    volumes:
      - /opt/peertube/data:/data
      - /opt/peertube/config:/config
    depends_on:
      - postgres
      - redis

  postgres:
    image: postgres:16-alpine
    container_name: peertube-postgres
    restart: unless-stopped
    volumes:
      - /opt/peertube/postgresql:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=peertube
      - POSTGRES_PASSWORD=peertube_secure_password_change_me
      - POSTGRES_DB=peertube

  redis:
    image: redis:7-alpine
    container_name: peertube-redis
    restart: unless-stopped
    volumes:
      - /opt/peertube/redis:/data
    command: redis-server --appendonly yes

Deployment

Verify Hardware Access

For Intel Quick Sync:

# Check devices exist
ls -la /dev/dri/

# Verify permissions
groups $USER

# Add if missing
sudo usermod -a -G video,render $USER

# Verify render group ID
getent group render

For NVIDIA:

# Test NVIDIA runtime
docker run --rm --runtime=nvidia nvidia/cuda:12.0-base nvidia-smi

# Verify NVIDIA Container Toolkit
nvidia-ctk --version

Start PeerTube

cd /opt/peertube
docker-compose up -d

Monitor Startup

# Watch logs
docker logs -f peertube

# Look for successful startup
# "HTTP server listening on port 9000"
# "Database ready"

First startup takes several minutes as PeerTube initializes the database.

Create Admin Account

# Create initial admin user
docker exec -it peertube npm run reset-password -- -u root

# Set admin email and password when prompted

Access Web Interface

Access https://peertube.yourdomain.com (after setting up reverse proxy) or http://YOUR-SERVER-IP:9000

Login:

  • Username: root
  • Password: The one you just set

Reverse Proxy Setup with Caddy

PeerTube requires a reverse proxy for production use. Caddy is recommended for automatic SSL.

Install Caddy

Create /opt/caddy/docker-compose.yml:

version: '3.8'

services:
  caddy:
    image: caddy:latest
    container_name: caddy
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /opt/caddy/Caddyfile:/etc/caddy/Caddyfile
      - /opt/caddy/data:/data
      - /opt/caddy/config:/config

Create Caddyfile

Create /opt/caddy/Caddyfile:

peertube.yourdomain.com {
    reverse_proxy peertube:9000

    # Increase timeouts for large video uploads
    request_body {
        max_size 8GB
    }

    # WebSocket support for live streaming
    @websocket {
        header Connection *Upgrade*
        header Upgrade websocket
    }
    reverse_proxy @websocket peertube:9000
}

Start Caddy

cd /opt/caddy
docker-compose up -d

Caddy automatically obtains SSL certificate from Let’s Encrypt.

Configure DNS

Create DNS A record:

  • Name: peertube
  • Type: A
  • Value: YOUR-PUBLIC-IP
  • TTL: 3600

Wait for DNS propagation (5-30 minutes).

Initial Configuration

Admin Setup

Access https://peertube.yourdomain.com and log in as root.

Step 1: Instance Information

  1. Navigate to Administration → Configuration → Instance
  2. Instance Details:
    • Instance name: Your PeerTube Name
    • Short description: Brief tagline
    • Description: Detailed about your instance
    • Terms of service: Your TOS
    • Code of conduct: Community guidelines
    • Moderation information: Your moderation policy

Step 2: Instance Settings

  1. Administration → Configuration → Basic
  2. Categories: Enable video categories you’ll use
  3. Languages: Select supported languages
  4. Default NSFW policy: Blur, Hide, or Display
  5. Instance default theme: Dark or Light

Step 3: Contact Information

  1. Administrator email: [email protected]
  2. Contact form: Enable if desired
  3. Services section: Link your other platforms

Transcoding Configuration

Enable Hardware Transcoding:

  1. Administration → Configuration → Transcoding
  2. Enable transcoding: Yes
  3. Enable HLS transcoding: Yes (recommended)
  4. Enable WebTorrent transcoding: Yes
  5. Transcoding threads: 0 (automatic) or number of cores

Video Resolutions: Select which resolutions to transcode:

  • 240p: Mobile/very slow connections
  • 360p: Low quality
  • 480p: Standard definition
  • 720p: HD (recommended minimum)
  • 1080p: Full HD (recommended)
  • 1440p: 2K (optional)
  • 2160p: 4K (if storage permits)

Profile Configuration:

  1. Transcoding profile: vod_profile

  2. For Intel Quick Sync:

    • Video codec: h264_qsv
    • Additional parameters: -preset medium
  3. For NVIDIA NVENC:

    • Video codec: h264_nvenc
    • Additional parameters: -preset p4 -tune hq
  4. For CPU:

    • Video codec: libx264
    • Additional parameters: -preset veryfast

Live Streaming Transcoding:

  1. Enable live streaming: Yes
  2. Allow live streaming: Yes
  3. Live transcoding: Yes
  4. Maximum live instances running: 10 (adjust based on resources)
  5. Maximum live duration: 3 hours (adjust as needed)

Storage Configuration

Video Storage:

  1. Administration → Configuration → Storage

  2. Object Storage (optional but recommended):

    • Enable: For scalability
    • S3-compatible endpoint: For MinIO or AWS S3
    • Bucket name: peertube-videos
    • Prefix: videos/
    • Access key and secret key
  3. Local Storage (default):

    • Videos directory: /data/videos
    • Streaming playlists: /data/streaming-playlists

Storage Quotas:

  1. Administration → Configuration → Users
  2. Default video quota per user: 5 GB (adjust)
  3. Default daily upload limit: 2 GB (adjust)

Federation Configuration

Enable Federation:

  1. Administration → Configuration → Federation
  2. Enable federation: Yes
  3. Federate unlisted videos: No (recommended)
  4. Follow instance: Automatically follow back: No (manual control)

Following Other Instances:

  1. Administration → Federation → Following
  2. Add instances to follow:
    • Enter instance URL: https://other-peertube.com
    • Click Follow
  3. Followed instances share their videos in your federated feed

Instance Blocklist:

  1. Administration → Federation → Blocklist
  2. Block unwanted instances:
    • Add instance domain to block
    • Prevents federation with that instance

Public Instance List:

  1. Administration → Configuration → Instance
  2. List your instance on public directory: Yes (optional)
  3. Helps others discover your instance

User Management

Creating Users

Manual User Creation:

  1. Administration → Users → Create user
  2. Username: newuser
  3. Email: [email protected]
  4. Password: Auto-generate or set
  5. Video quota: 5 GB
  6. Role: User or Moderator

User Registration:

  1. Administration → Configuration → Signup
  2. Enable signup: Yes or No
  3. Signup limit: Maximum users allowed
  4. Require email verification: Yes (recommended)
  5. User default video quota: 5 GB

User Roles

Role Types:

  • User: Upload videos, create channels
  • Moderator: Manage content, moderate comments
  • Administrator: Full system access

Moderator Permissions:

  1. Select user → Edit
  2. Role: Moderator
  3. Grant permissions:
    • Remove any video
    • Block/unblock users
    • Manage comments
    • Access abuse reports

Channel Management

Channels are how users organize content:

  1. Users create channels for different topics
  2. Each channel has its own branding
  3. Channels can be followed independently

Admin Channel Management:

  1. Administration → Video Channels
  2. View all channels
  3. Remove inappropriate channels
  4. Feature quality channels

Video Upload and Management

Upload Interface

Manual Upload:

  1. Click “Upload” icon (top right)
  2. Select video file
  3. Video Details:
    • Title: Descriptive title
    • Description: Detailed information
    • Channel: Select channel
    • Category: Choose category
    • License: Select appropriate license
    • Language: Video language
    • Tags: Relevant keywords
    • Privacy: Public, Unlisted, Private, Internal

Advanced Options:

  • Enable comments: Yes/No
  • Enable download: Yes/No
  • Wait for transcoding: Process before publishing
  • Schedule publication: Publish at specific time

Video Processing

Transcoding Queue:

  1. Administration → Jobs
  2. View transcoding jobs
  3. Monitor progress
  4. Retry failed jobs

Processing Priority:

  • Live streams: Highest priority
  • Recently uploaded: High priority
  • Older content: Background processing

Playlist Management

Create Playlists:

  1. My Library → Playlists → Create
  2. Name: Playlist title
  3. Description: What the playlist contains
  4. Privacy: Public, Unlisted, Private
  5. Add videos to playlist

Featured Playlists: Admins can feature playlists on homepage:

  1. Administration → Homepage
  2. Add playlist to featured section

Live Streaming Setup

Enable Live Streaming

System Configuration:

  1. Administration → Configuration → Live Streaming
  2. Enable live streaming: Yes
  3. Max live streaming instances: 10
  4. Max duration per live: 3 hours
  5. Allow replay: Yes (save stream as VOD)

User Live Permissions:

  1. Administration → Configuration → Live Streaming
  2. Allow users to create live streams: Yes
  3. Live transcoding: Yes (multiple qualities)

Create Live Stream

As User:

  1. Click “Upload” → “Go Live”

  2. Live Settings:

    • Title: Stream title
    • Description: What you’ll stream
    • Category: Gaming, Education, etc.
    • Privacy: Public, Unlisted, Private
    • Save replay: Yes (converts to VOD after)
  3. Get Stream Key:

    • RTMP URL: rtmp://peertube.yourdomain.com/live
    • Stream Key: Generated unique key
    • Copy both for OBS

OBS Configuration for PeerTube

Stream Settings:

  1. Settings → Stream
  2. Service: Custom
  3. Server: rtmp://peertube.yourdomain.com/live
  4. Stream Key: Your PeerTube live stream key

Output Settings:

  1. Settings → Output → Streaming
  2. Encoder: Hardware encoder (NVENC/QuickSync) or x264
  3. Rate Control: CBR
  4. Bitrate: 4500 kbps (1080p) or 2500 kbps (720p)
  5. Keyframe Interval: 2
  6. Preset: Quality or High Quality

Video Settings:

  1. Settings → Video
  2. Base Resolution: 1920x1080
  3. Output Resolution: 1920x1080 or 1280x720
  4. FPS: 30 or 60

Start Streaming:

  1. Configure scenes in OBS
  2. Click “Start Streaming”
  3. Stream appears live on PeerTube
  4. Monitor viewer count in PeerTube

Stream Replay: After stream ends:

  • Automatically saved as video (if enabled)
  • Appears in your channel
  • Transcoded to multiple qualities

Federation in Detail

How Federation Works

ActivityPub Protocol:

  • PeerTube uses ActivityPub for federation
  • Compatible with Mastodon, Pixelfed, etc.
  • Users can follow channels from their Mastodon account
  • Video posts appear in Fediverse feeds

Following Other Instances:

  1. Your instance can follow other PeerTube instances
  2. Videos from followed instances appear in federated feed
  3. Users can follow channels across instances
  4. Comments and likes federate across instances

Setting Up Federation

Follow an Instance:

  1. Administration → Federation → Following
  2. Enter instance URL: https://other-peertube.com
  3. Click “Follow”
  4. Other instance may require approval

Instance Discovery: Browse PeerTube instances:

  • instances.joinpeertube.org
  • Find instances by topic, language, size
  • Follow instances aligned with your content

Cross-Instance Following: Users from other instances can follow your channels:

  1. Share channel URL: https://peertube.yourdomain.com/c/channel-name
  2. Users paste in their instance search
  3. Click follow
  4. Updates federate automatically

Moderating Federated Content

Block Instances:

  1. Administration → Federation → Muted Instances
  2. Add instance domain to block
  3. Prevents all interaction with that instance

Mute Accounts:

  1. Administration → Moderation → Muted Accounts
  2. Mute problematic accounts from other instances
  3. Hides their comments and interactions

Advanced Features

Plugins and Themes

Install Plugins:

  1. Administration → Plugins/Themes
  2. Search available plugins
  3. Popular plugins:
    • Auto Block Videos: Automatically moderate content
    • YouTube Import: Import videos from YouTube
    • RSS Feed: Generate RSS feeds
    • OpenID Connect: SSO authentication

Install Custom Plugin:

docker exec -it peertube npm run plugin:install -- --path /path/to/plugin

Custom Themes:

  1. Administration → Plugins/Themes → Themes
  2. Install community themes
  3. Set as default or user-selectable

Video Import

Import from URL:

  1. Upload → Import
  2. Enter video URL (YouTube, Vimeo, etc.)
  3. Video downloads and transcodes
  4. Appears in your channel

Bulk Import: For migrating large libraries:

# Use PeerTube CLI
docker exec -it peertube npm run import-videos --   --target-url https://peertube.yourdomain.com   --channel-name your-channel   --import-url https://youtube.com/playlist?list=PLAYLIST_ID

Search and Discovery

Configure Search:

  1. Administration → Configuration → Search
  2. Enable search index: Yes
  3. Search in descriptions: Yes
  4. Search in tags: Yes

External Search Engines: PeerTube instances can be indexed:

  • sepiasearch.org: PeerTube-specific search
  • Standard search engines via sitemap

P2P and WebTorrent

P2P Video Distribution:

  • Viewers help distribute video via WebTorrent
  • Reduces server bandwidth significantly
  • More viewers = more distributed bandwidth

Configure P2P:

  1. Administration → Configuration → P2P
  2. Enable P2P: Yes
  3. Viewers share video while watching
  4. Disable per-video if needed

Privacy Considerations:

  • P2P reveals viewer IP addresses
  • Can be disabled per-video
  • Users can disable in their settings

Performance Optimization

Transcoding Optimization

Hardware Transcoding Benefits:

  • Intel Quick Sync: 5-10x faster than CPU
  • NVIDIA NVENC: 10-15x faster than CPU
  • Lower CPU usage and power consumption
  • Handle more concurrent transcodes

Optimize Transcoding Queue:

  1. Administration → Jobs
  2. Monitor job queue
  3. Increase concurrent jobs if resources allow
  4. Schedule heavy transcoding during off-peak

Storage Optimization

Object Storage (S3): For large deployments, use object storage:

MinIO Setup:

# Add to docker-compose.yml
  minio:
    image: minio/minio:latest
    container_name: peertube-minio
    command: server /data --console-address ":9001"
    ports:
      - "9100:9000"
      - "9101:9001"
    volumes:
      - /opt/minio/data:/data
    environment:
      - MINIO_ROOT_USER=peertube
      - MINIO_ROOT_PASSWORD=minio_secure_password

Configure PeerTube for MinIO:

  1. Create bucket in MinIO console
  2. Administration → Configuration → Object Storage
  3. Enable object storage: Yes
  4. Endpoint: http://minio:9000
  5. Access key: peertube
  6. Secret key: minio_secure_password
  7. Bucket: peertube-videos

Database Optimization

PostgreSQL Tuning: Edit /opt/peertube/postgresql/postgresql.conf:

# Memory settings
shared_buffers = 2GB
effective_cache_size = 6GB
work_mem = 64MB

# Performance
max_connections = 200
random_page_cost = 1.1

# Logging
log_min_duration_statement = 1000

Database Maintenance:

# Vacuum database monthly
docker exec peertube-postgres vacuumdb -U peertube -d peertube --analyze

# Reindex if needed
docker exec peertube-postgres reindexdb -U peertube -d peertube

Monitoring and Analytics

Built-in Statistics

Instance Statistics:

  1. Administration → Stats
  2. View metrics:
    • Total videos
    • Total users
    • Total local comments
    • Total video views

Video Analytics:

  1. My Library → Videos
  2. Select video → Stats
  3. View:
    • Total views
    • Views per day
    • Watch time
    • Retention graph

External Monitoring

Prometheus Metrics: Enable in production.yaml:

metrics:
  enabled: true
  prometheus:
    endpoint: /metrics

Add to Prometheus configuration:

scrape_configs:
  - job_name: 'peertube'
    static_configs:
      - targets: ['peertube:9000']
    metrics_path: '/metrics'

Grafana Dashboard: Import PeerTube dashboard for Grafana:

  • Visualization of video views
  • Transcoding queue length
  • Federation activity
  • Storage usage

Troubleshooting

Common Issues

Issue: Videos Not Transcoding

Diagnostics:

# Check transcoding jobs
docker exec peertube npm run jobs:list

# Check FFmpeg
docker exec peertube ffmpeg -version

# View logs
docker logs peertube | grep -i transcode

Solutions:

  • Verify hardware device mapping
  • Check transcoding enabled in settings
  • Ensure sufficient disk space
  • Review job queue for errors

Issue: Federation Not Working

Diagnostics:

# Test ActivityPub endpoint
curl https://peertube.yourdomain.com/.well-known/webfinger

# Check federation logs
docker logs peertube | grep -i federation

Solutions:

  • Verify HTTPS is working correctly
  • Check firewall allows outbound connections
  • Ensure domain is publicly accessible
  • Verify WebFinger endpoint responds

Issue: High Database Load

Solutions:

  • Run VACUUM ANALYZE on database
  • Increase PostgreSQL shared_buffers
  • Add database indexes if needed
  • Enable connection pooling

Issue: Upload Failures

Solutions:

  • Check disk space: df -h
  • Verify user quota hasn’t been exceeded
  • Increase max upload size in Caddy
  • Check file permissions on data directory

Issue: SMTP Not Sending Emails

Diagnostics:

# Test SMTP configuration
docker logs peertube | grep -i smtp

Solutions:

  • Verify SMTP credentials
  • Check SMTP port is correct (587 for TLS)
  • Enable “less secure apps” if using Gmail
  • Use app-specific password for Gmail
  • Test with different SMTP provider

Security Best Practices

Access Control

Admin Account Security:

  • Use strong password (20+ characters)
  • Enable 2FA via plugin if available
  • Limit admin accounts to necessary personnel
  • Regular password rotation

User Registration:

  • Require email verification
  • Enable manual approval if desired
  • Set reasonable upload quotas
  • Monitor new user activity

Network Security

Firewall Configuration:

# Allow HTTP/HTTPS
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

# Allow RTMP for live streaming
sudo ufw allow 1935/tcp

# Restrict direct access to PeerTube port
sudo ufw deny 9000/tcp

SSL/TLS:

  • Use strong cipher suites
  • Keep SSL certificates updated
  • Use HSTS headers
  • Disable old TLS versions

Content Moderation

Abuse Reports:

  1. Administration → Moderation → Abuse Reports
  2. Review reported content
  3. Take action: Remove, warn, ban user

Auto-Moderation:

  • Install auto-moderation plugins
  • Configure word filters
  • Block known spam accounts
  • Enable CAPTCHA for signup

DMCA Compliance:

  • Create clear DMCA policy
  • Respond promptly to takedown requests
  • Keep logs of requests and actions
  • Consider DMCA agent registration

Backup and Recovery

Database Backup

Automated Backup Script:

#!/bin/bash
# /opt/scripts/backup-peertube.sh

BACKUP_DIR="/backups/peertube"
DATE=$(date +%Y%m%d_%H%M%S)

mkdir -p $BACKUP_DIR

# Backup PostgreSQL database
docker exec peertube-postgres pg_dump -U peertube peertube |   gzip > $BACKUP_DIR/peertube-db-$DATE.sql.gz

# Backup configuration
tar -czf $BACKUP_DIR/peertube-config-$DATE.tar.gz /opt/peertube/config

# Keep last 14 backups
ls -t $BACKUP_DIR/peertube-db-*.sql.gz | tail -n +15 | xargs -r rm
ls -t $BACKUP_DIR/peertube-config-*.tar.gz | tail -n +15 | xargs -r rm

echo "Backup completed: $BACKUP_DIR/peertube-db-$DATE.sql.gz"

Schedule with Cron:

# Daily at 2 AM
0 2 * * * /opt/scripts/backup-peertube.sh

Video Backup

Backup Strategy:

  • Videos stored in /opt/peertube/data/videos
  • Large storage requirements
  • Consider incremental backups

Using Restic:

# Install restic
restic init --repo /backups/peertube-videos

# Backup videos
restic backup /opt/peertube/data/videos   --repo /backups/peertube-videos

# Restore specific file
restic restore latest   --repo /backups/peertube-videos   --target /restore/location

Disaster Recovery

Full Restore:

# Stop containers
cd /opt/peertube
docker-compose down

# Restore database
gunzip < peertube-db-20250115.sql.gz |   docker exec -i peertube-postgres psql -U peertube -d peertube

# Restore configuration
tar -xzf peertube-config-20250115.tar.gz -C /

# Restore videos (if needed)
restic restore latest --repo /backups/peertube-videos --target /opt/peertube/data

# Restart containers
docker-compose up -d

Next Steps

Immediate Actions

After completing basic setup:

  1. Create your first channel and upload test video
  2. Configure transcoding with hardware acceleration
  3. Set up federation by following other instances
  4. Enable live streaming and test with OBS
  5. Configure SMTP for email notifications
  6. Set up automated backups

Growing Your Instance

Content Strategy:

  • Define your niche or focus
  • Create content calendar
  • Cross-post to build audience
  • Engage with federated community

Community Building:

  • Welcome other users if allowing signups
  • Create featured playlists
  • Highlight quality content
  • Moderate actively and fairly

Advanced Configurations

Full Media Platform:

  • PeerTube for video hosting
  • Mastodon for social interaction
  • Pixelfed for image sharing
  • Unified Fediverse presence

Professional Features:

  • Custom plugins for unique features
  • Advanced analytics and insights
  • CDN integration for global delivery
  • Multi-server deployment

Resources

Official Documentation:

  • joinpeertube.org: Official website
  • docs.joinpeertube.org: Complete documentation
  • github.com/Chocobozzz/PeerTube: Source code

Community Support:

Related Guides:

  • Federation and ActivityPub
  • Hardware transcoding setup
  • Object storage configuration
  • Mastodon integration

Build your independent video platform and join the federated future of content sharing!