Cryptpad: Unterschied zwischen den Versionen

Aus Hostsharing Wiki
Zur Navigation springen Zur Suche springen
K (Update Release 5.3.0)
(Refactoring, mit angepasster .htaccess)
 
(8 dazwischenliegende Versionen von 4 Benutzern werden nicht angezeigt)
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.  


Die aktuelle Version wird mit Node Version 16.x betrieben. 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]].
[[NodeJS]].


Zeile 20: Zeile 20:
Nach dem Aufschalten der Domain 'cryptpad.hs-example.de' passen wir die generierte Verzeichnisstruktur der Domain wie folgt an:
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
<syntaxhighlight lang=shell>
rm -rf subs/www subs-ssl/www htdocs-ssl/.htaccess
cd ~/doms/cryptpad.hs-example.de
mkdir subs/api subs-ssl/api
rm -rf subs/www subs-ssl/www htdocs-ssl/.htaccess
mkdir subs/sandbox subs-ssl/sandbox
</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:


cd ~/doms/cryptpad.hs-example.de
<syntaxhighlight lang=apache line>
# 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  
 
DirectoryIndex disabled
# cd ~/doms/cryptpad.hs-example.de
RewriteEngine On
# cat subs-ssl/sandbox/.htaccess
RewriteBase /
 
RewriteCond %{HTTP:UPGRADE} ^WebSocket$          [NC,OR]
DirectoryIndex disabled
RewriteCond %{HTTP:CONNECTION} ^Upgrade$          [NC]
RewriteEngine On
RewriteRule .* ws://127.0.0.1:30001%{REQUEST_URI}  [proxy]
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{HTTP:UPGRADE} ^WebSocket$          [NC,OR]
RewriteRule .* http://127.0.0.1:30001%{REQUEST_URI} [proxy,last]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$          [NC]
RewriteRule .* ws://127.0.0.1:30002%{REQUEST_URI}  [proxy]
cat htdocs-ssl/.htaccess  
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
DirectoryIndex disabled
RewriteRule .* http://127.0.0.1:30001%{REQUEST_URI} [proxy,last]
RewriteEngine On
 
RewriteBase /   
# cd ~/doms/cryptpad.hs-example.de
RewriteCond %{REQUEST_FILENAME} !-f
# cat htdocs-ssl/.htaccess
RewriteCond %{HTTP:UPGRADE} ^WebSocket$          [NC,OR]
 
RewriteCond %{HTTP:CONNECTION} ^Upgrade$          [NC]
DirectoryIndex disabled
RewriteRule .* ws://127.0.0.1:30001%{REQUEST_URI}  [proxy]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteBase /   
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* http://127.0.0.1:30001%{REQUEST_URI} [proxy,last]
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]
</syntaxhighlight>
 
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>
# 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


Eine weitere '.htaccess'-Datei liegt direkt im Hauptverzeichnis der Domain (die überlangen Zeilen beachten):
# 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


cd ~/doms/cryptpad.hs-example.de
</syntaxhighlight>
cat .htaccess
Header Set Access-Control-Allow-Origin "https://api.cryptpad.hs-example.de"
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"
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)/#"


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


cd $HOME
<syntaxhighlight lang=shell>
mkdir data
cd $HOME
mkdir data/blob
mkdir data
mkdir data/block
mkdir data/blob
cd $HOME/doms/cryptpad.hs-example.de/htdocs-ssl/
mkdir data/block
ln -s /home/pacs/xyz00/users/cryptpad/data/blob .
cd $HOME/doms/cryptpad.hs-example.de/htdocs-ssl/
ln -s /home/pacs/xyz00/users/cryptpad/data/block .
ln -s /home/pacs/xyz00/users/cryptpad/data/blob .
ln -s /home/pacs/xyz00/users/cryptpad/data/block .
</syntaxhighlight>


Dieser Link muss angepasst werden, wenn der Blob-Speicher in den Zusatzspeicher unter /home/storage verschoben wird (siehe unten)!
Dieser Link muss angepasst werden, wenn der Blob-Speicher in den Zusatzspeicher unter /home/storage verschoben wird (siehe unten)!
Zeile 82: Zeile 136:
== Installation von NodeJS ==
== Installation von NodeJS ==


Nach dieser [https://wiki.hostsharing.net/index.php?title=NodeJS Anleitung] hier im Wiki wird mit Hilfe von 'nvm' 'node' in der Version 16 installiert.
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.


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


cd $HOME
<syntaxhighlight lang=shell>
npm install -g bower
source ~/.profile
git clone https://github.com/xwiki-labs/cryptpad.git cryptpad
cd $HOME
cd cryptpad  
git clone https://github.com/xwiki-labs/cryptpad.git cryptpad
# aktuelle Version nachsehen
cd cryptpad  
git checkout 5.3.0
# aktuelle Version nachsehen
npm install
git checkout 2025.3.1
bower install  
npm ci
cd config
npm run install:components
cp config.example.js config.js
cd config
vi config.js
cp config.example.js config.js
vi config.js
</syntaxhighlight>
 
Meine Konfiguration in der 'config.js':
Meine Konfiguration in der 'config.js':


$ cat config.js
<syntaxhighlight lang=javascript line>
module.exports = {
// $ cat config.js
module.exports = {
   
   
    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,
    maxWorkers: 4,
  websocketPort: 30002,
    /*
  maxWorkers: 4,
    adminKeys: [
  /*
        "[admin@cryptpad.hs-example.de/xxxxxxxxxxxxxxxxxxxxxxxx=]",
  adminKeys: [
    ],
      "[admin@cryptpad.hs-example.de/xxxxxxxxxxxxxxxxxxxxxxxx=]",
    */
  ],
    inactiveTime: 90, // days
  */
    archiveRetentionTime: 15,
  inactiveTime: 90, // days
    accountRetentionTime: 365,
  archiveRetentionTime: 15,
    maxUploadSize: 8 * 1024 * 1024,
  accountRetentionTime: 365,
    filePath: '/home/pacs/xyz00/users/cryptpad/data/file/',
  maxUploadSize: 8 * 1024 * 1024,
    archivePath: '/home/pacs/xyz00/users/cryptpad/data/archive/',
  filePath: '/home/pacs/xyz00/users/cryptpad/data/file/',
    pinPath: '/home/pacs/xyz00/users/cryptpad/data/pins',
  archivePath: '/home/pacs/xyz00/users/cryptpad/data/archive/',
    taskPath: '/home/pacs/xyz00/users/cryptpad/data/tasks',
  pinPath: '/home/pacs/xyz00/users/cryptpad/data/pins',
    blockPath: '/home/pacs/xyz00/users/cryptpad/data/block',
  taskPath: '/home/pacs/xyz00/users/cryptpad/data/tasks',
    blobPath: '/home/pacs/xyz00/users/cryptpad/data/blob',
  blockPath: '/home/pacs/xyz00/users/cryptpad/data/block',
    blobStagingPath: '/home/pacs/xyz00/users/cryptpad/data/blobstage',
  blobPath: '/home/pacs/xyz00/users/cryptpad/data/blob',
    decreePath: '/home/pacs/xyz00/users/cryptpad/data/decrees',
  blobStagingPath: '/home/pacs/xyz00/users/cryptpad/data/blobstage',
    logPath: '/home/pacs/xyz00/users/cryptpad/data/logs',
  decreePath: '/home/pacs/xyz00/users/cryptpad/data/decrees',
    logToStdout: true,
  logPath: '/home/pacs/xyz00/users/cryptpad/data/logs',
    logLevel: 'info',
  logToStdout: true,
    logFeedback: false,
  logLevel: 'info',
    verbose: false,
  logFeedback: false,
    installMethod: 'unspecified',
  verbose: false,
};
  installMethod: 'unspecified',
};
</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:


    blobPath: '/home/storage/xyz00/users/cryptpad/data/blob',
<syntaxhighlight lang=javascript line>
  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>


== Start des Cryptpad ==
== Start des Cryptpad ==
Zeile 143: Zeile 214:
Ich starte das Cryptpad zunächst einfach mit dem 'nohup'-Kommando:
Ich starte das Cryptpad zunächst einfach mit dem 'nohup'-Kommando:


cd ~/cryptpad
<syntaxhighlight lang=shell>
nohup node server &
source ~/.profile
cd ~/cryptpad
nohup node server &
</syntaxhighlight>


== Cryptpad als Dienst starten ==
== Cryptpad als Dienst starten ==
Zeile 152: Zeile 226:
Dazu legen wir eine Systemd-Unit an:
Dazu legen wir eine Systemd-Unit an:


mkdir -p $HOME/.config/systemd/user/
<syntaxhighlight lang=shell>
vi $HOME/.config/systemd/user/cryptpad.service
mkdir -p $HOME/.config/systemd/user/
vi $HOME/.config/systemd/user/cryptpad.service
</syntaxhighlight>


Der Inhalt der Datei soll sein:  
Der Inhalt der Datei soll sein:  


[Unit]
<syntaxhighlight lang=ini line>
Description=Cryptpad
[Unit]
Description=Cryptpad
After=network.target
   
   
[Service]
[Service]
Type=simple
Type=simple
WorkingDirectory=%h/cryptpad
WorkingDirectory=%h/cryptpad
Environment="PATH=%h/.nvm/versions/node/v16.19.1/bin:/usr/local/bin:/usr/bin:/bin"
Environment="NODE_ENV=production"
ExecStart=%h/.nvm/versions/node/v16.19.1/bin/node server.js
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]
[Install]
WantedBy=default.target
WantedBy=default.target
</syntaxhighlight>


(Die Node-Version im Pfad muss ggf. korrigiert werden)
(Die Node-Version im Pfad muss ggf. korrigiert werden)
Zeile 182: Zeile 265:
* [https://docs.cryptpad.fr/de/ Dokumentation in deutscher Sprache]
* [https://docs.cryptpad.fr/de/ Dokumentation in deutscher Sprache]
* [https://docs.cryptpad.fr/de/admin_guide/installation.html Installationanleitung]
* [https://docs.cryptpad.fr/de/admin_guide/installation.html Installationanleitung]
* [https://github.com/tpokorra/Hostsharing-Ansible-Cryptpad Ansible Playbook für Hostsharing]
* [https://codeberg.org/tpokorra/hs.ansible/src/branch/main/playbooks/cryptpad Ansible Playbook für Hostsharing]




Zeile 189: Zeile 272:
[[Kategorie:Installationsanleitungen]]
[[Kategorie:Installationsanleitungen]]
[[Kategorie:Software]]
[[Kategorie:Software]]
[[Kategorie:CalDAV]]
[[Kategorie:Ansible Playbook]]
[[Kategorie:Ansible Playbook]]

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