PeerTube Integration with MinIO Object Storage

Distinguish transcoding server and storage server

PeerTube Integration with MinIO Object Storage

1. Prerequisite

These two prerequisites are very important:

  • In the previous article, I introduced Complete Guide of MinIO Docker Deployment. This tutorial assumes that you have successfully configured MinIO.
  • You are assumed to have deployed PeerTube via Docker. If you have not, please refer to Peertube v3 Docker Installation
    Note: It’s recommended that you have PeerTube v5 deployed instead of v3. The process is almost the same and I will skip the similar configuration.

2. PeerTube Configuration

Peertube server should be (recommended) different from MinIO server.

  • Go to PeerTube server and edit the config file
cd /your/path/peertube/docker-volume/config
cp production.yaml production.yaml.bak
nano production.yaml
  • The default content can be like this:
listen:
  hostname: '0.0.0.0'
  port: 9000

# Correspond to your reverse proxy "listen" configuration
webserver:
  https: true
  hostname: undefined
  port: 443

rates_limit:
  login:
    # 15 attempts in 5 min
    window: 5 minutes
    max: 15
  ask_send_email:
    # 3 attempts in 5 min
    window: 5 minutes
    max: 3

# Proxies to trust to get real client IP
# If you run PeerTube just behind a local proxy (nginx), keep 'loopback'
# If you run PeerTube behind a remote proxy, add the proxy IP address (or subnet)
trust_proxy:
  - 'loopback'
  - 'linklocal'
  - 'uniquelocal'

# Your database name will be database.name or "peertube"+database.suffix
database:
  hostname: 'postgres'
  port: 5432
  ssl: false
  suffix: ''
  username: 'postgres'
  password: 'postgres'

# Redis server for short time storage
redis:
  hostname: 'redis'
  port: 6379
  auth: null

# From the project root directory
storage:
  tmp: '../data/tmp/'
  avatars: '../data/avatars/'
  videos: '../data/videos/'
  streaming_playlists: '../data/streaming-playlists'
  redundancy: '../data/redundancy/'
  logs: '../data/logs/'
  previews: '../data/previews/'
  thumbnails: '../data/thumbnails/'
  torrents: '../data/torrents/'
  captions: '../data/captions/'
  cache: '../data/cache/'
  plugins: '../data/plugins/'
  # Overridable client files : logo.svg, favicon.png and icons/*.png (PWA) in client/dist/assets/images
  # Could contain for example assets/images/favicon.png
  # If the file exists, peertube will serve it
  # If not, peertube will fallback to the default fil
  client_overrides: '../data/client-overrides/'

log:
  level: 'info' # debug/info/warning/error

tracker:
  enabled: true
  reject_too_many_announces: false # false because we have issues with docker ws ip/port forwarding

admin:
  email: null
  • Comment out 2 lines under the storage block , which is videos and streaming_playlists. Add a new block named object_storage. (example below, please modify yourself)
(...)

# From the project root directory
storage:
  tmp: '../data/tmp/'
  avatars: '../data/avatars/'
#  videos: '../data/videos/'
#  streaming_playlists: '../data/streaming-playlists'
  redundancy: '../data/redundancy/'
  logs: '../data/logs/'
  previews: '../data/previews/'
  thumbnails: '../data/thumbnails/'
  torrents: '../data/torrents/'
  captions: '../data/captions/'
  cache: '../data/cache/'
  plugins: '../data/plugins/'
  # Overridable client files : logo.svg, favicon.png and icons/*.png (PWA) in client/dist/assets/images
  # Could contain for example assets/images/favicon.png
  # If the file exists, peertube will serve it
  # If not, peertube will fallback to the default fil
  client_overrides: '../data/client-overrides/'

object_storage:
  enabled: true
  endpoint: 'minio.example.com'
  region: 'us-west-1'
  videos:
    bucket_name: 'testbucket'
    prefix: 'videos/'
  streaming_playlists:
    bucket_name: 'testbucket'
    prefix: 'streaming-playlists/'
  credentials:
    access_key_id: 'your_access_key'
    secret_access_key: 'your_secret_key'

(...)

Note: This is an example of using a single bucket. You have to change the endpoint with your own MinIO, also the bucket_name, access_key_id, secret_access_key. For region, since you self-host the MinIO, you can put any value in the following list:
us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-west-2, eu-west-3, eu-central-1, eu-north-1, ap-east-1, ap-south-1, ap-southeast-1, ap-southeast-2, ap-northeast-1, ap-northeast-2, ap-northeast-3, me-south-1, sa-east-1, us-gov-west-1, us-gov-east-1, cn-north-1, cn-northwest-1.

  • Restart the docker container
docker-compose restart

Now your video will be stored in your MinIO object storage instead of PeerTube local server. You can go to your MinIO console -> Object Browser -> Your_Bucket_Name, to check the videos.

Enjoy!


Copyright statement: Unless otherwise stated, all articles on this blog adopt the CC BY-NC-SA 4.0 license agreement. For non-commercial reprints and citations, please indicate the author: Henry, and original article URL. For commercial reprints, please contact the author for authorization.