去中心化开源视频项目peertube部署
PeerTube是去中心化开源视频网站项目,可以自己部署,并和“联邦宇宙”建立联系;
采用docker-compose部署,内容如下
version: '3'
services:
postgres:
image: postgres:14-alpine
container_name: postgres
restart: always
networks:
- public-net
ports:
- "5432:5432"
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: passwd
POSTGRES_DB: peertube
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- ./postgres/data:/var/lib/postgresql/data
redis:
image: redis:7-alpine
container_name: redis
restart: always
networks:
- public-net
ports:
- "6379:6379"
volumes:
- ./redis/data:/data
peertube:
image: peertube:production-buster
container_name: peertube
restart: always
networks:
- public-net
ports:
- "1935:1935"
- "9500:9000"
environment:
PEERTUBE_DB_HOSTNAME: postgres
PEERTUBE_DB_USERNAME: root
PEERTUBE_DB_PASSWORD: passwd
PEERTUBE_DB_NAME: peertube
PEERTUBE_DB_SSL: "false"
PEERTUBE_DB_PORT: 5432
PEERTUBE_REDIS_HOSTNAME: redis
PEERTUBE_REDIS_PORT: 6379
PEERTUBE_WEBSERVER_HOSTNAME: example.ex.com #访问域名,不需要https
PEERTUBE_WEBSERVER_PORT: 443 #访问端口号,
PEERTUBE_WEBSERVER_HTTPS: "false" #是否https
PEERTUBE_SECRET: ac74705834083f543cb5cd66d6e00cc8c104088
PEERTUBE_SMTP_USERNAME: #邮件用户名
PEERTUBE_SMTP_PASSWORD: #邮件密钥
PEERTUBE_SMTP_HOSTNAME: #邮件服务器,按需填写
PEERTUBE_SMTP_PORT: #邮件服务器端口
PEERTUBE_SMTP_FROM: #邮件用户名
PEERTUBE_SMTP_TLS: "true"#是否启用ssl,true表示使用
PEERTUBE_SMTP_DISABLE_STARTTLS: "false"
PEERTUBE_ADMIN_EMAIL: #管理员邮箱
PEERTUBE_SIGNUP_ENABLED: "false"#是否启用注册,false不允许注册
volumes:
- ./peertube/data:/data
- ./peertube/config:/config
- assets:/app/client/dist
networks:
public-net:
driver: bridge
volumes:
assets:
一开始部署时总是连不上数据库,后来先单独启动数据库,并初始化,然后再链接就好了
数据库初始化思路,开启临时的容器,进行初始化
docker run --name peertube_database_temp \
-e POSTGRES_USER=root \
-e POSTGRES_PASSWORD=passwd \
-e POSTGRES_DB=peertube \
-p 5432:5432 \
-d postgres:14-alpine
在数据库初始化完成后,停止并删除临时容器docker stop peertube_database_temp
docker rm peertube_database_temp
再启动docker-compose up -d
然后访问对应端口即可,密码需要查看启动记录docker logs peertube
找到用户名和密码,用户名为root,密码是随机的字串,登陆后再修改即可
目前通过nginx代理,可以https访问,正常上传和播放视频;nginx代理使用https时docker-compose中的PEERTUBE_WEBSERVER_HTTPS: "false" #是否https
要改为true才行,否则视频无法播放
参考nginx配置
server {
listen 443 ssl;
server_name 改为你的域名;
ssl_certificate 证书路径;
ssl_certificate_key 证书密钥路径;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:443;
proxy_pass http://127.0.0.1:你的peertube端口见docker-compose文件;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 0;
proxy_buffering off;
proxy_cache off;
}
}