Cryptpad: Unterschied zwischen den Versionen

Aus Hostsharing Wiki
Zur Navigation springen Zur Suche springen
(kann kein CalDAV)
(Refactoring, mit angepasster .htaccess)
 
Zeile 9: Zeile 9:
= Installation =
= Installation =


Mitglieder, die einen Managed Webspace im Shared Hosting nutzen, müssen für ihre Cryptpad-Installation einen "eigenen Serverdienst" beim Hostsharing-Service anmelden. Diese Option ist im Shared Hosting kostenpflichtig. Für den Serverdienst wird ein IP-Port mit dem Server vereinbart. Im Beispiel wird Port '30001' genutzt.
Mitglieder, die einen Managed Webspace im Shared Hosting nutzen, müssen für ihre Cryptpad-Installation einen "eigenen Serverdienst" beim Hostsharing-Service anmelden. Diese Option ist im Shared Hosting kostenpflichtig. Für den Serverdienst werden zwei IP-Ports mit dem Server vereinbart. Im Beispiel werden Ports '30001' und '30002' genutzt.


Für die Installation werden mit Hilfe von HSAdmin ein User (hier: 'xyz00-cryptpad') und eine Domain angelegt (hier: 'cryptpad.hs-example.de'). Die Entwickler empfehlen die Nutzung von zwei Domains für eine Cryptpad Installation. Wir nutzen hier eine 'leichtgewichtige' Subdomain 'api.cryptpad.hs-example.de', die bei Hostsharing ohne weitere Konfiguration nutzbar ist.  
Für die Installation werden mit Hilfe von HSAdmin ein User (hier: 'xyz00-cryptpad') und eine Domain angelegt (hier: 'cryptpad.hs-example.de'). Die Entwickler empfehlen die Nutzung von zwei Domains für eine Cryptpad Installation. Wir nutzen hier eine 'leichtgewichtige' Subdomain 'sandbox.cryptpad.hs-example.de', die bei Hostsharing ohne weitere Konfiguration nutzbar ist.  


Für die aktuelle Version wird Node LTS (Version 20.x) empfohlen. Zur Installation (erfolgt weiter unten) siehe
Für die aktuelle Version wird Node LTS (Version 22.x) empfohlen. Zur Installation (erfolgt weiter unten) siehe
[[NodeJS]]. Es kann aber auch das Node 18 von Debian Bookworm verwendet werden.
[[NodeJS]].


== Webserver Konfiguration ==
== Webserver Konfiguration ==
Zeile 23: Zeile 23:
cd ~/doms/cryptpad.hs-example.de
cd ~/doms/cryptpad.hs-example.de
rm -rf subs/www subs-ssl/www htdocs-ssl/.htaccess
rm -rf subs/www subs-ssl/www htdocs-ssl/.htaccess
mkdir subs/api subs-ssl/api
mkdir subs/sandbox subs-ssl/sandbox
</syntaxhighlight>
</syntaxhighlight>


In die Verzeichnisse 'subs/api', 'subs-ssl/api' und 'htdocs-ssl' werden jeweils Dateien mit dem Namen '.htaccess' zur Konfiguration des Apache Webserver abgelegt:
In die Verzeichnisse 'subs/sandbox', 'htdocs', 'subs-ssl/sandbox' und 'htdocs-ssl' werden jeweils Dateien mit dem Namen '.htaccess' zur Konfiguration des Apache Webserver abgelegt:


<syntaxhighlight lang=apache line>
<syntaxhighlight lang=apache line>
# cd ~/doms/cryptpad.hs-example.de
# cd ~/doms/cryptpad.hs-example.de
# cat subs/api/.htaccess  
# cat subs/sandbox/.htaccess


Redirect permanent / https://api.cryptpad.hs-example.de/
Redirect permanent / https://sandbox.cryptpad.hs-example.de/
 
# cat subs-ssl/api/.htaccess  
# cd ~/doms/cryptpad.hs-example.de
# cat subs-ssl/sandbox/.htaccess


DirectoryIndex disabled
DirectoryIndex disabled
Zeile 41: Zeile 42:
RewriteCond %{HTTP:UPGRADE} ^WebSocket$          [NC,OR]
RewriteCond %{HTTP:UPGRADE} ^WebSocket$          [NC,OR]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$          [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$          [NC]
RewriteRule .* ws://127.0.0.1:30001%{REQUEST_URI}  [proxy]
RewriteRule .* ws://127.0.0.1:30002%{REQUEST_URI}  [proxy]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule .* http://127.0.0.1:30001%{REQUEST_URI} [proxy,last]
RewriteRule .* http://127.0.0.1:30001%{REQUEST_URI} [proxy,last]
 
# cat htdocs-ssl/.htaccess  
# cd ~/doms/cryptpad.hs-example.de
# cat htdocs-ssl/.htaccess


DirectoryIndex disabled
DirectoryIndex disabled
Zeile 53: Zeile 55:
RewriteCond %{HTTP:UPGRADE} ^WebSocket$          [NC,OR]
RewriteCond %{HTTP:UPGRADE} ^WebSocket$          [NC,OR]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$          [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$          [NC]
RewriteRule .* ws://127.0.0.1:30001%{REQUEST_URI}  [proxy]
RewriteRule .* ws://127.0.0.1:30002%{REQUEST_URI}  [proxy]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
Zeile 59: Zeile 61:
</syntaxhighlight>
</syntaxhighlight>


Eine weitere '.htaccess'-Datei liegt direkt im Hauptverzeichnis der Domain (die überlangen Zeilen beachten):
Eine weitere '.htaccess'-Datei liegt direkt im Hauptverzeichnis der Domain:
 
* Beachte die überlangen Zeilen!
* Wir orientieren uns an der Beispiel Konfiguration des NGinx Servers vom Cryptpad Projekt: [https://github.com/cryptpad/cryptpad/blob/main/docs/example-advanced.nginx.conf]


<syntaxhighlight lang=apache line>
<syntaxhighlight lang=apache line>
# cd ~/doms/cryptpad.hs-example.de
# cd ~/doms/cryptpad.hs-example.de
# cat .htaccess  
# cat .htaccess  
Header Set Access-Control-Allow-Origin "https://api.cryptpad.hs-example.de"
 
# OnlyOffice fonts may be loaded from both domains
SetEnvIf REQUEST_URI ^/common/onlyoffice/.*/fonts/.*$ ALLOW_ALL_ORIGINS
Header Set Access-Control-Allow-Origin "*" env=ALLOW_ALL_ORIGINS
Header Set Access-Control-Allow-Origin "https://sandbox.cryptpad.hs-example.de" env=!ALLOW_ALL_ORIGINS
 
Header Set Access-Control-Allow-Methods "GET, POST, OPTIONS"
Header Set Access-Control-Allow-Methods "GET, POST, OPTIONS"
Header Set Access-Control-Allow-Headers "DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range"
Header Set Access-Control-Allow-Headers "DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range"
Zeile 72: Zeile 82:
Header Set Cross-Origin-Resource-Policy "cross-origin"
Header Set Cross-Origin-Resource-Policy "cross-origin"
Header Set Cross-Origin-Embedder-Policy "require-corp"
Header Set Cross-Origin-Embedder-Policy "require-corp"
Header Set Content-Security-Policy "default-src 'none'; child-src https://cryptpad.hs-example.de; worker-src 'self'; media-src blob:; style-src 'unsafe-inline' 'self' https://cryptpad.hs-example.de; script-src 'self' resource: https://cryptpad.hs-example.de; connect-src 'self' blob: https://cryptpad.hs-example.de https://api.cryptpad.hs-example.de wss://cryptpad.hs-example.de; font-src 'self' data: https://cryptpad.hs-example.de; img-src 'self' data: blob: https://cryptpad.hs-example.de; frame-src 'self' blob: https://api.cryptpad.hs-example.de; frame-ancestors 'self' https://cryptpad.hs-example.de;" "expr=%{REQUEST_URI} !~ m#^/(sheet|common)/#"
 
Header Set Content-Security-Policy "default-src 'none'; child-src https://cryptpad.hs-example.de; worker-src 'self'; media-src blob:; style-src 'unsafe-inline' 'self' https://cryptpad.hs-example.de; script-src 'self' resource: https://cryptpad.hs-example.de 'unsafe-eval' 'unsafe-inline'; connect-src 'self' blob: https://cryptpad.hs-example.de https://api.cryptpad.hs-example.de wss://cryptpad.hs-example.de; font-src 'self' data: https://cryptpad.hs-example.de; img-src 'self' data: blob: https://cryptpad.hs-example.de; frame-src 'self' blob: https://api.cryptpad.hs-example.de; frame-ancestors 'self' https://cryptpad.hs-example.de;" "expr=%{REQUEST_URI} =~ m#^/(sheet|common)/#"
# the following assets are loaded via the sandbox domain
# they unfortunately still require exceptions to the sandboxing to work correctly.
# if ($uri ~ ^/(?:sheet|doc|presentation)/inner.html) { set $unsafe 1; }
# if ($uri ~ ^/common/onlyoffice/.*/.*\.html) { set $unsafe 1; }
# if ($uri ~ ^/common/onlyoffice/dist/.*/sdkjs/common/spell/spell/spell.js.*$) { set $unsafe 1; }
SetEnvIf REQUEST_URI ^/(sheet|doc|presentation)/inner\.html SET_UNSAFE
SetEnvIf REQUEST_URI ^/common/onlyoffice/.*/.*\.html SET_UNSAFE
SetEnvIf REQUEST_URI ^/common/onlyoffice/dist/.*/sdkjs/common/spell/spell/spell.js.* SET_UNSAFE
 
# everything except the sandbox domain is a privileged scope, as they might be used to handle keys
# if ($host != $sandbox_domain) { set $unsafe 0; }
SetEnvIfNoCase Host ^sandbox.*$ IS_SANDBOX
SetEnvIfNoCase Host ^(?!sandbox\.).*$ NOT_SANDBOX
SetEnvIfNoCase Host ^(?!sandbox\.).*$ !SET_UNSAFE
 
# this iframe is an exception. Office file formats are converted outside of the sandboxed scope
# because of bugs in Chromium-based browsers that incorrectly ignore headers that are supposed to enable
# the use of some modern APIs that we require when javascript is run in a cross-origin context.
# We've applied other sandboxing techniques to mitigate the risk of running WebAssembly in this privileged scope
# if ($uri ~ ^/unsafeiframe/inner\.html) { set $unsafe 1; }
SetEnvIf REQUEST_URI ^/unsafeiframe/inner\.html SET_UNSAFE=1
 
# !SET_UNSAFE: script-src without exceptions
Header Set Content-Security-Policy "default-src 'none'; child-src https://cryptpad.hs-example.de; worker-src 'self'; media-src blob:; style-src 'unsafe-inline' 'self' https://cryptpad.hs-example.de; script-src 'self' resource: https://cryptpad.hs-example.de; connect-src 'self' https://cryptpad.hs-example.de blob: wss://cryptpad.hs-example.de https://sandbox.cryptpad.hs-example.de; font-src 'self' data: https://cryptpad.hs-example.de; img-src 'self' data: blob: https://cryptpad.hs-example.de; frame-src 'self' https://sandbox.cryptpad.hs-example.de blob:; frame-ancestors 'self' https: vector:" env=!SET_UNSAFE
# SET_UNSAFE: script-src with unsafe exceptions
Header Set Content-Security-Policy "default-src 'none'; child-src https://cryptpad.hs-example.de; worker-src 'self'; media-src blob:; style-src 'unsafe-inline' 'self' https://cryptpad.hs-example.de; script-src 'self' 'unsafe-eval' 'unsafe-inline' resource: https://cryptpad.hs-example.de; connect-src 'self' https://cryptpad.hs-example.de blob: wss://cryptpad.hs-example.de https://sandbox.cryptpad.hs-example.de; font-src 'self' data: https://cryptpad.hs-example.de; img-src 'self' data: blob: https://cryptpad.hs-example.de; frame-src 'self' https://sandbox.cryptpad.hs-example.de blob:; frame-ancestors 'self' https: vector:" env=SET_UNSAFE
 
# for debugging
Header Set DebugAllowAllOrigins "allowall" env=ALLOW_ALL_ORIGINS
Header Set DebugAllowOrigins "sandboxonly" env=!ALLOW_ALL_ORIGINS
Header Set DebugSetUnsafe "unsafe" env=SET_UNSAFE
Header Set DebugIsSafe "safe" env=!SET_UNSAFE
Header Set DebugIsSandbox "sandbox" env=IS_SANDBOX
Header Set DebugIsMainDomain "maindomain" env=NOT_SANDBOX
 
</syntaxhighlight>
</syntaxhighlight>


Zeile 92: Zeile 136:
== Installation von NodeJS ==
== Installation von NodeJS ==


Nach dieser [https://wiki.hostsharing.net/index.php?title=NodeJS Anleitung] hier im Wiki kann mit Hilfe von 'nvm' 'node' in der Version 20 installiert werden.
Nach dieser [https://wiki.hostsharing.net/index.php?title=NodeJS Anleitung] hier im Wiki sollte mit Hilfe von 'nvm' 'node' in der Version 22 installiert werden.
 
Es geht aber auch ohne selbstinstalliertes Node: die Version 18 von Debian Bookworm lässt sich ebenso gut verwenden.


== Installation des Cryptpad ==
== Installation des Cryptpad ==


<syntaxhighlight lang=shell>
<syntaxhighlight lang=shell>
source ~/.profile
cd $HOME
cd $HOME
npm install -g bower
git clone https://github.com/xwiki-labs/cryptpad.git cryptpad
git clone https://github.com/xwiki-labs/cryptpad.git cryptpad
cd cryptpad  
cd cryptpad  
# aktuelle Version nachsehen
# aktuelle Version nachsehen
git checkout 2024.9.0
git checkout 2025.3.1
npm install
npm ci
bower install  
npm run install:components
cd config
cd config
cp config.example.js config.js
cp config.example.js config.js
Zeile 119: Zeile 161:
   
   
   httpUnsafeOrigin: 'https://cryptpad.hs-example.de',
   httpUnsafeOrigin: 'https://cryptpad.hs-example.de',
   httpSafeOrigin: "https://api.cryptpad.hs-example.de",
   httpSafeOrigin: "https://sandbox.cryptpad.hs-example.de",
   httpAddress: '127.0.0.1',
   httpAddress: '127.0.0.1',
   httpPort: 30001,
   httpPort: 30001,
  websocketPort: 30002,
   maxWorkers: 4,
   maxWorkers: 4,
   /*
   /*
Zeile 149: Zeile 192:
</syntaxhighlight>
</syntaxhighlight>


Der Admin-Key wird später ergänzt. Der erste registrierte User im Cryptpad kann den Schlüssel aus seinem Profil herauskopieren.
Der Admin-Key wird später ergänzt. Der erste registrierte User im Cryptpad kann den öffentlichen Schlüssel aus seinem Profil herauskopieren.


Wenn größere Datenmengen erwartet werden, kann der 'blobPath' in den Zusatzspeicher verlegt werden:
Wenn größere Datenmengen erwartet werden, kann der 'blobPath' in den Zusatzspeicher verlegt werden:
Zeile 155: Zeile 198:
<syntaxhighlight lang=javascript line>
<syntaxhighlight lang=javascript line>
   blobPath: '/home/storage/xyz00/users/cryptpad/data/blob',
   blobPath: '/home/storage/xyz00/users/cryptpad/data/blob',
</syntaxhighlight>
== Installation von onlyoffice ==
Es kann onlyoffice installiert werden, um auch das Bearbeiten von z.B. Calc/Excel Dateien zu ermöglichen.
<syntaxhighlight lang=shell>
source ~/.profile
cd ~/cryptpad
/install-onlyoffice.sh --accept-license
</syntaxhighlight>
</syntaxhighlight>


Zeile 162: Zeile 215:


<syntaxhighlight lang=shell>
<syntaxhighlight lang=shell>
source ~/.profile
cd ~/cryptpad
cd ~/cryptpad
nohup node server &
nohup node server &
Zeile 188: Zeile 242:
WorkingDirectory=%h/cryptpad
WorkingDirectory=%h/cryptpad
Environment="NODE_ENV=production"
Environment="NODE_ENV=production"
Environment="PATH=/usr/local/bin:/usr/bin:/bin"
Environment="PATH=%h/node_modules/.bin:/usr/local/bin:/usr/bin:/bin"
ExecStart=/usr/bin/node server.js
ExecStart=%h/.nvm/versions/node/v22.16.0/bin/node server
Restart=always
Restart=always
PrivateTmp=true
PrivateTmp=true

Aktuelle Version vom 11. Juni 2025, 20:33 Uhr

Cryptpad

Cryptpad ist ein Online-Office, dass in erster Linie im Internet-Browser zu bedienen ist. Das Alleinstellungsmerkmal ist die Ende-zu-Ende-Verschlüsselung aller Dokumente. Die Entschlüsselung und die Verschlüsselung erfolgen im Browser. Auf dem Server sind keinerlei lesbare Daten abgelegt.

Cryptpad bietet Editoren für formatierte Textdokumente (im HTML-Format) und für Markdown-Dateien und andere Textdateien. Der Anwendungsfall der Tabellenkalkulation wird durch Onlyoffice-Tabellen abgedeckt. Präsentationen können mit Hilfe von Markdown erstellt werden. Bilder und PDF-Dokumente können in die Umgebung hochgeladen und im Browser betrachtet werden. Ein Kalender und ein Kanbanboard zur Aufgabenverwaltung vervollständigen das Angebot.

Das Projekt stellt eine gute Installationsanleitung bereit. Leider ist die Konfiguration des Webservers nur für NGinX dokumentiert, so dass für die Konfiguration des Apache Webserver einige Experimente notwendig wurden.

Installation

Mitglieder, die einen Managed Webspace im Shared Hosting nutzen, müssen für ihre Cryptpad-Installation einen "eigenen Serverdienst" beim Hostsharing-Service anmelden. Diese Option ist im Shared Hosting kostenpflichtig. Für den Serverdienst werden zwei IP-Ports mit dem Server vereinbart. Im Beispiel werden Ports '30001' und '30002' genutzt.

Für die Installation werden mit Hilfe von HSAdmin ein User (hier: 'xyz00-cryptpad') und eine Domain angelegt (hier: 'cryptpad.hs-example.de'). Die Entwickler empfehlen die Nutzung von zwei Domains für eine Cryptpad Installation. Wir nutzen hier eine 'leichtgewichtige' Subdomain 'sandbox.cryptpad.hs-example.de', die bei Hostsharing ohne weitere Konfiguration nutzbar ist.

Für die aktuelle Version wird Node LTS (Version 22.x) empfohlen. Zur Installation (erfolgt weiter unten) siehe NodeJS.

Webserver Konfiguration

Nach dem Aufschalten der Domain 'cryptpad.hs-example.de' passen wir die generierte Verzeichnisstruktur der Domain wie folgt an:

cd ~/doms/cryptpad.hs-example.de
rm -rf subs/www subs-ssl/www htdocs-ssl/.htaccess
mkdir subs/sandbox subs-ssl/sandbox

In die Verzeichnisse 'subs/sandbox', 'htdocs', 'subs-ssl/sandbox' und 'htdocs-ssl' werden jeweils Dateien mit dem Namen '.htaccess' zur Konfiguration des Apache Webserver abgelegt:

# cd ~/doms/cryptpad.hs-example.de
# cat subs/sandbox/.htaccess

Redirect permanent / https://sandbox.cryptpad.hs-example.de/

# cd ~/doms/cryptpad.hs-example.de
# cat subs-ssl/sandbox/.htaccess

DirectoryIndex disabled
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP:UPGRADE} ^WebSocket$           [NC,OR]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$          [NC]
RewriteRule .* ws://127.0.0.1:30002%{REQUEST_URI}  [proxy]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule .* http://127.0.0.1:30001%{REQUEST_URI} [proxy,last]

# cd ~/doms/cryptpad.hs-example.de
# cat htdocs-ssl/.htaccess

DirectoryIndex disabled
RewriteEngine On
RewriteBase /   
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP:UPGRADE} ^WebSocket$           [NC,OR]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$          [NC]
RewriteRule .* ws://127.0.0.1:30002%{REQUEST_URI}  [proxy]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule .* http://127.0.0.1:30001%{REQUEST_URI} [proxy,last]

Eine weitere '.htaccess'-Datei liegt direkt im Hauptverzeichnis der Domain:

  • Beachte die überlangen Zeilen!
  • Wir orientieren uns an der Beispiel Konfiguration des NGinx Servers vom Cryptpad Projekt: [1]
# cd ~/doms/cryptpad.hs-example.de
# cat .htaccess 

# OnlyOffice fonts may be loaded from both domains
SetEnvIf REQUEST_URI ^/common/onlyoffice/.*/fonts/.*$ ALLOW_ALL_ORIGINS
Header Set Access-Control-Allow-Origin "*" env=ALLOW_ALL_ORIGINS
Header Set Access-Control-Allow-Origin "https://sandbox.cryptpad.hs-example.de" env=!ALLOW_ALL_ORIGINS

Header Set Access-Control-Allow-Methods "GET, POST, OPTIONS"
Header Set Access-Control-Allow-Headers "DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range"
Header Set Access-Control-Max-Age "1728000"
Header Set X-XSS-Protection "1; mode=block"
Header Set X-Content-Type-Options "nosniff"
Header Set Cross-Origin-Resource-Policy "cross-origin"
Header Set Cross-Origin-Embedder-Policy "require-corp"

# the following assets are loaded via the sandbox domain
# they unfortunately still require exceptions to the sandboxing to work correctly.
# if ($uri ~ ^/(?:sheet|doc|presentation)/inner.html) { set $unsafe 1; }
# if ($uri ~ ^/common/onlyoffice/.*/.*\.html) { set $unsafe 1; }
# if ($uri ~ ^/common/onlyoffice/dist/.*/sdkjs/common/spell/spell/spell.js.*$) { set $unsafe 1; }
SetEnvIf REQUEST_URI ^/(sheet|doc|presentation)/inner\.html SET_UNSAFE
SetEnvIf REQUEST_URI ^/common/onlyoffice/.*/.*\.html SET_UNSAFE
SetEnvIf REQUEST_URI ^/common/onlyoffice/dist/.*/sdkjs/common/spell/spell/spell.js.* SET_UNSAFE

# everything except the sandbox domain is a privileged scope, as they might be used to handle keys
# if ($host != $sandbox_domain) { set $unsafe 0; }
SetEnvIfNoCase Host ^sandbox.*$ IS_SANDBOX
SetEnvIfNoCase Host ^(?!sandbox\.).*$ NOT_SANDBOX
SetEnvIfNoCase Host ^(?!sandbox\.).*$ !SET_UNSAFE

# this iframe is an exception. Office file formats are converted outside of the sandboxed scope
# because of bugs in Chromium-based browsers that incorrectly ignore headers that are supposed to enable
# the use of some modern APIs that we require when javascript is run in a cross-origin context.
# We've applied other sandboxing techniques to mitigate the risk of running WebAssembly in this privileged scope
# if ($uri ~ ^/unsafeiframe/inner\.html) { set $unsafe 1; }
SetEnvIf REQUEST_URI ^/unsafeiframe/inner\.html SET_UNSAFE=1

# !SET_UNSAFE: script-src without exceptions
Header Set Content-Security-Policy "default-src 'none'; child-src https://cryptpad.hs-example.de; worker-src 'self'; media-src blob:; style-src 'unsafe-inline' 'self' https://cryptpad.hs-example.de; script-src 'self' resource: https://cryptpad.hs-example.de; connect-src 'self' https://cryptpad.hs-example.de blob: wss://cryptpad.hs-example.de https://sandbox.cryptpad.hs-example.de; font-src 'self' data: https://cryptpad.hs-example.de; img-src 'self' data: blob: https://cryptpad.hs-example.de; frame-src 'self' https://sandbox.cryptpad.hs-example.de blob:; frame-ancestors 'self' https: vector:" env=!SET_UNSAFE
# SET_UNSAFE: script-src with unsafe exceptions
Header Set Content-Security-Policy "default-src 'none'; child-src https://cryptpad.hs-example.de; worker-src 'self'; media-src blob:; style-src 'unsafe-inline' 'self' https://cryptpad.hs-example.de; script-src 'self' 'unsafe-eval' 'unsafe-inline' resource: https://cryptpad.hs-example.de; connect-src 'self' https://cryptpad.hs-example.de blob: wss://cryptpad.hs-example.de https://sandbox.cryptpad.hs-example.de; font-src 'self' data: https://cryptpad.hs-example.de; img-src 'self' data: blob: https://cryptpad.hs-example.de; frame-src 'self' https://sandbox.cryptpad.hs-example.de blob:; frame-ancestors 'self' https: vector:" env=SET_UNSAFE

# for debugging
Header Set DebugAllowAllOrigins "allowall" env=ALLOW_ALL_ORIGINS
Header Set DebugAllowOrigins "sandboxonly" env=!ALLOW_ALL_ORIGINS
Header Set DebugSetUnsafe "unsafe" env=SET_UNSAFE
Header Set DebugIsSafe "safe" env=!SET_UNSAFE
Header Set DebugIsSandbox "sandbox" env=IS_SANDBOX
Header Set DebugIsMainDomain "maindomain" env=NOT_SANDBOX

Zwei Datenverzeichnisse werden angelegt und direkt ins 'htdocs-ssl' verlinkt:

cd $HOME
mkdir data
mkdir data/blob
mkdir data/block
cd $HOME/doms/cryptpad.hs-example.de/htdocs-ssl/
ln -s /home/pacs/xyz00/users/cryptpad/data/blob .
ln -s /home/pacs/xyz00/users/cryptpad/data/block .

Dieser Link muss angepasst werden, wenn der Blob-Speicher in den Zusatzspeicher unter /home/storage verschoben wird (siehe unten)!

Installation von NodeJS

Nach dieser Anleitung hier im Wiki sollte mit Hilfe von 'nvm' 'node' in der Version 22 installiert werden.

Installation des Cryptpad

source ~/.profile
cd $HOME
git clone https://github.com/xwiki-labs/cryptpad.git cryptpad
cd cryptpad 
# aktuelle Version nachsehen
git checkout 2025.3.1
npm ci
npm run install:components
cd config
cp config.example.js config.js
vi config.js

Meine Konfiguration in der 'config.js':

// $ cat config.js
module.exports = {
 
   httpUnsafeOrigin: 'https://cryptpad.hs-example.de',
   httpSafeOrigin: "https://sandbox.cryptpad.hs-example.de",
   httpAddress: '127.0.0.1',
   httpPort: 30001,
   websocketPort: 30002,
   maxWorkers: 4,
   /*
   adminKeys: [
       "[admin@cryptpad.hs-example.de/xxxxxxxxxxxxxxxxxxxxxxxx=]",
   ],
   */
   inactiveTime: 90, // days
   archiveRetentionTime: 15,
   accountRetentionTime: 365,
   maxUploadSize: 8 * 1024 * 1024,
   filePath: '/home/pacs/xyz00/users/cryptpad/data/file/',
   archivePath: '/home/pacs/xyz00/users/cryptpad/data/archive/',
   pinPath: '/home/pacs/xyz00/users/cryptpad/data/pins',
   taskPath: '/home/pacs/xyz00/users/cryptpad/data/tasks',
   blockPath: '/home/pacs/xyz00/users/cryptpad/data/block',
   blobPath: '/home/pacs/xyz00/users/cryptpad/data/blob',
   blobStagingPath: '/home/pacs/xyz00/users/cryptpad/data/blobstage',
   decreePath: '/home/pacs/xyz00/users/cryptpad/data/decrees',
   logPath: '/home/pacs/xyz00/users/cryptpad/data/logs',
   logToStdout: true,
   logLevel: 'info',
   logFeedback: false,
   verbose: false,
   installMethod: 'unspecified',
};

Der Admin-Key wird später ergänzt. Der erste registrierte User im Cryptpad kann den öffentlichen Schlüssel aus seinem Profil herauskopieren.

Wenn größere Datenmengen erwartet werden, kann der 'blobPath' in den Zusatzspeicher verlegt werden:

   blobPath: '/home/storage/xyz00/users/cryptpad/data/blob',

Installation von onlyoffice

Es kann onlyoffice installiert werden, um auch das Bearbeiten von z.B. Calc/Excel Dateien zu ermöglichen.

source ~/.profile
cd ~/cryptpad
/install-onlyoffice.sh --accept-license

Start des Cryptpad

Ich starte das Cryptpad zunächst einfach mit dem 'nohup'-Kommando:

source ~/.profile
cd ~/cryptpad
nohup node server &

Cryptpad als Dienst starten

Die Cryptpad-Prozesse sollen von Systemd als Dienst automatisch gestartet werden.

Dazu legen wir eine Systemd-Unit an:

mkdir -p $HOME/.config/systemd/user/
vi $HOME/.config/systemd/user/cryptpad.service

Der Inhalt der Datei soll sein:

[Unit]
Description=Cryptpad
After=network.target
 
[Service]
Type=simple
WorkingDirectory=%h/cryptpad
Environment="NODE_ENV=production"
Environment="PATH=%h/node_modules/.bin:/usr/local/bin:/usr/bin:/bin"
ExecStart=%h/.nvm/versions/node/v22.16.0/bin/node server
Restart=always
PrivateTmp=true
NoNewPrivileges=true
 
[Install]
WantedBy=default.target

(Die Node-Version im Pfad muss ggf. korrigiert werden)

Der Dienst wird aktiviert und gestartet mit:

systemctl --user daemon-reload
systemctl --user enable cryptpad.service
systemctl --user start cryptpad.service

weiterführende Links