From abd325042dc75f8c84a2ac96440cbcfeb8581b93 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 26 Mar 2018 09:20:46 +0530 Subject: [PATCH 01/22] Tmp fix for https://github.com/YunoHost-Apps/peertube_ynh/issues/5,fix https://github.com/YunoHost-Apps/peertube_ynh/issues/8,upgrade file,option to change port,password check for lenght,multi_instance --- check_process | 6 +- conf/nginx.conf | 36 ++++++++--- conf/production.yaml | 52 ++++++++++++---- conf/systemd.service | 3 +- manifest.json | 13 +++- scripts/install | 29 +++++++-- scripts/remove | 4 +- scripts/upgrade | 145 +++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 255 insertions(+), 33 deletions(-) create mode 100644 scripts/upgrade diff --git a/check_process b/check_process index af9b88c..1885393 100644 --- a/check_process +++ b/check_process @@ -18,7 +18,7 @@ setup_public=1 upgrade=0 backup_restore=0 - multi_instance=0 + multi_instance=1 incorrect_path=0 port_already_use=1 change_url=0 @@ -36,5 +36,5 @@ Level 9=0 Level 10=0 ;;; Options -Email= -Notification=none +Email=anmol@datamol.org +Notification=yes diff --git a/conf/nginx.conf b/conf/nginx.conf index 7aa8e7b..b7fe0bc 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,18 +1,37 @@ -location / { + location ~ ^/client/(.*\.(js|css|woff2|otf|ttf|woff|eot))$ { + add_header Cache-Control "public, max-age=31536000, immutable"; + + alias __FINALPATH__/client/dist/$1; + } + + location ~ ^/static/(thumbnails|avatars)/(.*)$ { + add_header Cache-Control "public, max-age=31536000, immutable"; + + alias /home/yunohost.app/__NAME__/storage/$1/$2; + } + + location / { if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } - proxy_pass http://localhost:9000; + proxy_pass http://localhost:__PORT__; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - # For the video upload + # Hard limit, PeerTube does not support videos > 4GB client_max_body_size 4G; + proxy_connect_timeout 600; + proxy_send_timeout 600; + proxy_read_timeout 600; + send_timeout 600; } - # Bypass PeerTube webseed route for better performances - location /static/webseed { + # Bypass PeerTube webseed route for better performances + location /static/webseed { + # Clients usually have 4 simultaneous webseed connections, so the real limit is 3MB/s per client + limit_rate 800k; + if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; @@ -27,9 +46,12 @@ location / { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; + + # Don't spam access log file with byte range requests + access_log off; } - alias __FINALPATH__/videos; + alias /home/yunohost.app/__NAME__/storage/videos; } # Websocket tracker @@ -42,5 +64,5 @@ location / { proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; - proxy_pass http://localhost:9000; + proxy_pass http://localhost:__PORT__; } diff --git a/conf/production.yaml b/conf/production.yaml index 8102f3f..2599f2d 100644 --- a/conf/production.yaml +++ b/conf/production.yaml @@ -1,5 +1,5 @@ listen: - port: 9000 + port: __PORT__ # Correspond to your reverse proxy "listen" configuration webserver: @@ -11,8 +11,8 @@ webserver: database: hostname: 'localhost' port: 5432 - suffix: '_prod' - username: 'peertube' + suffix: '___db_name__' + username: '__db_name__' password: '__db_pwd__' # Your object store @@ -21,22 +21,45 @@ redis: port: 6379 auth: null +# SMTP server to send emails +smtp: + hostname: null + port: 465 + username: null + password: null + tls: true + disable_starttls: false + ca_file: null # Used for self signed certificates + from_address: 'admin@__domain__' + # From the project root directory storage: - avatars: 'avatars/' - videos: 'videos/' - logs: 'logs/' - previews: 'previews/' - thumbnails: 'thumbnails/' - torrents: 'torrents/' - cache: 'cache/' + avatars: '/home/yunohost.app/__app__/storage/avatars/' + videos: '/home/yunohost.app/__app__/storage/videos/' + logs: '/home/yunohost.app/__app__/storage/logs/' + previews: '/home/yunohost.app/__app__/storage/previews/' + thumbnails: '/home/yunohost.app/__app__/storage/thumbnails/' + torrents: '/home/yunohost.app/__app__/storage/torrents/' + cache: '/home/yunohost.app/__app__/storage/cache/' log: level: 'info' # debug/info/warning/error +############################################################################### +# +# From this point, all the following keys can be overriden by the web interface +# (local-production.json file). If you need to change some values, prefer to +# use the web interface because the configuration will be automatically +# reloaded without any need to restart PeerTube. +# +# /!\ If you already have a local-production.json file, the modification of the +# following keys will have no effect /!\. +# +############################################################################### + cache: previews: - size: 1 # Max number of previews you want to cache + size: 100 # Max number of previews you want to cache admin: email: '__email__' @@ -62,10 +85,13 @@ transcoding: 720p: true 1080p: true +# Instance settings instance: name: 'PeerTube' - description: 'Welcome to this PeerTube instance!' # Support markdown - terms: 'No terms for now.' # Support markdown + short_description: 'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser with WebTorrent and Angular.' + description: '' # Support markdown + terms: '' # Support markdown + default_client_route: '/videos/trending' customizations: javascript: '' # Directly your JavaScript code (without