1 { lib, pkgs, config, ... }:
3 env = config.myEnv.tools.peertube;
4 cfg = config.myServices.websites.tools.peertube;
5 pcfg = config.services.peertube;
7 options.myServices.websites.tools.peertube = {
8 enable = lib.mkEnableOption "enable Peertube's website";
11 config = lib.mkIf cfg.enable {
14 configFile = config.secrets.fullPaths."webapps/tools-peertube";
16 users.users.peertube.extraGroups = [ "keys" ];
18 secrets.keys."webapps/tools-peertube" = {
25 port: ${toString config.myEnv.ports.peertube}
28 hostname: 'peertube.immae.eu'
31 hostname: '${env.postgresql.socket}'
34 username: '${env.postgresql.user}'
35 password: '${env.postgresql.password}'
39 socket: '${env.redis.socket}'
44 sendmail: '/run/wrappers/bin/sendmail'
45 from_address: 'peertube@tools.immae.eu'
47 tmp: '${pcfg.dataDir}/storage/tmp/'
48 avatars: '${pcfg.dataDir}/storage/avatars/'
49 videos: '${pcfg.dataDir}/storage/videos/'
50 streaming_playlists: '${pcfg.dataDir}/storage/streaming-playlists/'
51 redundancy: '${pcfg.dataDir}/storage/videos/'
52 logs: '${pcfg.dataDir}/storage/logs/'
53 previews: '${pcfg.dataDir}/storage/previews/'
54 thumbnails: '${pcfg.dataDir}/storage/thumbnails/'
55 torrents: '${pcfg.dataDir}/storage/torrents/'
56 captions: '${pcfg.dataDir}/storage/captions/'
57 cache: '${pcfg.dataDir}/storage/cache/'
58 plugins: '${pcfg.dataDir}/storage/plugins/'
59 client_overrides: '${pcfg.dataDir}/storage/client-overrides/'
63 services.websites.env.tools.modules = [
64 "headers" "proxy" "proxy_http" "proxy_wstunnel"
66 services.filesWatcher.peertube = {
68 paths = [ pcfg.configFile ];
71 services.websites.env.tools.vhostConfs.peertube = {
74 hosts = [ "peertube.immae.eu" ];
79 RewriteCond %{REQUEST_URI} ^/socket.io [NC]
80 RewriteCond %{QUERY_STRING} transport=websocket [NC]
81 RewriteRule /(.*) ws://localhost:${toString env.listenPort}/$1 [P,NE,QSA,L]
83 RewriteCond %{REQUEST_URI} ^/tracker/socket [NC]
84 RewriteRule /(.*) ws://localhost:${toString env.listenPort}/$1 [P,NE,QSA,L]
86 ProxyPass / http://localhost:${toString env.listenPort}/
87 ProxyPassReverse / http://localhost:${toString env.listenPort}/
90 RequestHeader set X-Real-IP %{REMOTE_ADDR}s