Gabe Rocks!

Couple of updates


  1. PeerTube S3 Uploads
  2. Kuma

Troubleshooting PeerTube S3 uploads

In the interest of being cost-efficient I’ve setup my PeerTube to use object storage to store and serve the videos.


  1. Configure PeerTube
  2. Upload videos
  3. Configure CORS

1. Configure PeerTube

Ensure you’ve got PeerTube setup.
From your peertube directory (or docker volume) you’ll want to update your config/local-production.json / config/localproduction.yaml file.

NOTE:At the time of writing, Updating your server configuration from the management console will ERASE your settings. This means you’ll want to make sure to back up your settings so you can copy over your changes when needed.

Then you’ll add your object storage settings to PeerTube. Using the repository’s production.yaml.example as a guide:

  enabled: true
  endpoint: ''
  region: 'us-east-1'
  upload_acl: #This is quite important, no real reason to change it.
    public: 'public-read'
    private: 'private'
    proxify_private_files: true #needed with the previous setting
# You can also use AWS_ACCESS_KEY_ID environment variable
    access_key_id: ''
# You can also use AWS_SECRET_ACCESS_KEY environment variable
    secret_access_key: ''
# Maximum amount to upload in one request to object storage 5-?MB
  max_upload_part: 100MB

#You have to configure both the "videos" and "streaming playlists location" they can't be the same destination, unless you put them on different buckets.
    prefix: 'pt-playlists'
    bucket_name: 'bucket_name'
    bucket_name: 'bucket_name'
    prefix: 'pt-videos'

2. Upload videos

This is the easy part, if you’ve already uploaded videos you can use the cli tool to move existing videos to storage

# Basic installation
cd /var/www/peertube/peertube-latest
sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-move-video-storage-job -- --to-object-storage --all-videos

# Docker installation
cd /var/www/peertube-docker
docker-compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-object-storage --all-videos

Otherwise, you can upload your new videos as normal, then PeerTube will:

  1. Store the Video
  2. Transcode the video
  3. Upload the video & transcodes to the Object storage

You’ll be able to check the status of the jobs from the management UI at: /admin/system/jobs from your instance.

What if the upload fails?

Fear not! As long as PeerTube has correctly created the folders, you can use the tool s3cmd to manually upload the files.

s3cmd put data/videos/$video s3://$bucket_name/pt-videos
s3cmd sync data/streaming-playlists/hls/$video_UUID s3://$bucket_name/pt-playlists/$video_UUID

Once complete peertube should simply complete the jobs faster when restarted.

My video isn’t listed in local videos

You’re going to need to set the video state manually to 1. You can do this from your postgres:

update video state=1 where UUID='$video-UUID';

I’d really recommend waiting before transcoding and uploads are finished. Also, your video may just be missing the language attibute if it’s not visible in the “local videos” page.

3. Configure CORS

Your object storage provider may not allow CORS by default. You’ll want to use s3cmd to update the headers

Uptime Monitoring with Kuma

A friend introduced me to Kuma which is an excellent self-hosted status reporting tool. I wanted to share my unique twist. Because I use ssh tunnels to provide services I can redirect 502 errors to the status page. This requires Kuma to stay on the VPS, which I’m perfectly fine with.

To get this result there are two major things you need to keep in mind:

  1. No Redirects If you simply add the nginx option to 502 to your status page, it will return a 502, and simply work, instead you’ll want to configure the monitor to want a specific api endpoint or page that won’t redirect. This means properly entering the url such as ````.

    Then you set the allowed redirects to 0 so it will properly report the service being down.

  2. Update the nginx config

    It’s quite as simple as adding:

    502; to each server block!

I like this temporary way of replacing the typical scary 502 - Bad Gateway nginx page in a way that provides more information. I’m quite impressed by kuma. It supports many different services for alerts, including matrix!

Reply to this post

Site Information PeerTube Kuma Nginx Object Storage
Prev B @ Next