Support of sandbox url is now required.
This commit is contained in:
parent
2bb6594f6c
commit
4cbbc5f932
@ -6,4 +6,4 @@
|
||||
backup_date="2019-11-03-0036"
|
||||
|
||||
|
||||
cp -a /var/www/cryptpad.BAK.${backup_date}/{blob,blobstage,block,datastore} /var/www/cryptpad/cryptpad/
|
||||
cp -a /var/www/cryptpad.BAK.${backup_date}/{blob,blobstage,block,datastore} /var/www/cryptpad/
|
||||
|
159
README.install
159
README.install
@ -11,6 +11,7 @@
|
||||
# -
|
||||
|
||||
cryptpad_url=cpad-01.oopen.de
|
||||
cryptpad_url=o13-pad.oopen.de
|
||||
|
||||
# bei vorgeschalteter authentifizierung funktioniert
|
||||
# eine *extra* sandbox url nicht. in diesem falle die gleiche
|
||||
@ -18,6 +19,9 @@ cryptpad_url=cpad-01.oopen.de
|
||||
#
|
||||
#cryptpad_sandbox_url=cpadsb-01.oopen.de
|
||||
cryptpad_sandbox_url="$cryptpad_url"
|
||||
cryptpad_sandbox_url="o13-padsb.oopen.de"
|
||||
|
||||
vhost_config_file="${cryptpad_url}.conf"
|
||||
|
||||
|
||||
# ----------
|
||||
@ -56,9 +60,16 @@ openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
|
||||
# - Create nginx configuration for CryptPad
|
||||
# -
|
||||
|
||||
cat <<EOF > /etc/nginx/sites-available/cpad-01.oopen.de.conf
|
||||
cat <<EOF > /etc/nginx/sites-available/${vhost_config_file}
|
||||
# -- $cryptpad_url
|
||||
|
||||
# we want restrict authentication to cryptpad sandbox urls "$cryptpad_sandbox_url"
|
||||
#
|
||||
#map \$http_host \$auth_type {
|
||||
# default "off"; #This will turn off auth-basic
|
||||
# $cryptpad_sandbox_url "Restricted"; #This or any other string will turn it back on
|
||||
#}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
@ -81,7 +92,7 @@ server {
|
||||
# In the event of an XSS vulnerability in CryptPad's front-end code
|
||||
# this will limit the amount of information accessible to attackers.
|
||||
set \$main_domain "$cryptpad_url";
|
||||
set \$sandbox_domain "$cryptpad_url";
|
||||
set \$sandbox_domain "$cryptpad_sandbox_url";
|
||||
|
||||
# CryptPad's dynamic content (websocket traffic and encrypted blobs)
|
||||
# can be served over separate domains. Using dedicated domains (or subdomains)
|
||||
@ -91,8 +102,21 @@ server {
|
||||
# If you do, they'll be added as exceptions to any rules which block connections to remote domains.
|
||||
set \$api_domain "$cryptpad_url";
|
||||
set \$files_domain "$cryptpad_url";
|
||||
EOF
|
||||
|
||||
if [[ "$cryptpad_url" = "$cryptpad_sandbox_url" ]]; then
|
||||
cat <<EOF >> /etc/nginx/sites-available/${vhost_config_file}
|
||||
|
||||
server_name $cryptpad_url;
|
||||
EOF
|
||||
else
|
||||
cat <<EOF >> /etc/nginx/sites-available/${vhost_config_file}
|
||||
|
||||
server_name $cryptpad_url $cryptpad_sandbox_url;
|
||||
EOF
|
||||
fi
|
||||
|
||||
cat <<EOF >> /etc/nginx/sites-available/${vhost_config_file}
|
||||
|
||||
ssl_certificate /var/lib/dehydrated/certs/$cryptpad_url/fullchain.pem;
|
||||
ssl_certificate_key /var/lib/dehydrated/certs/$cryptpad_url/privkey.pem;
|
||||
@ -117,7 +141,7 @@ server {
|
||||
# You'll need nginx 1.13.0 or better to support TLSv1.3
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
|
||||
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
|
||||
ssl_ciphers EECDH+AESGCM:EDH+AESGCM;
|
||||
|
||||
ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0
|
||||
|
||||
@ -152,15 +176,22 @@ server {
|
||||
#}
|
||||
# End Bad Bot Blocker Includes
|
||||
|
||||
set \$coop '';
|
||||
if (\$uri ~ ^\/sheet\/.*\$) { set \$coop 'same-origin'; }
|
||||
# Opt out of Google's FLoC Network
|
||||
add_header Permissions-Policy interest-cohort=();
|
||||
EOF
|
||||
|
||||
cat <<EOF >> /etc/nginx/sites-available/${vhost_config_file}
|
||||
|
||||
set \$coop '';
|
||||
#if (\$uri ~ ^\/(sheet|presentation|doc|convert)\/.*\$) { set \$coop 'same-origin'; }
|
||||
|
||||
# Enable SharedArrayBuffer in Firefox (for .xlsx export)
|
||||
add_header Cross-Origin-Resource-Policy cross-origin;
|
||||
add_header Cross-Origin-Opener-Policy \$coop;
|
||||
add_header Cross-Origin-Embedder-Policy require-corp;
|
||||
|
||||
# Insert the path to your CryptPad repository root here
|
||||
root /var/www/cryptpad/cryptpad;
|
||||
root /var/www/cryptpad;
|
||||
index index.html;
|
||||
error_page 404 /customize.dist/404.html;
|
||||
|
||||
@ -174,12 +205,11 @@ server {
|
||||
# Will not set any header if it is emptystring
|
||||
add_header Cache-Control \$cacheControl;
|
||||
|
||||
|
||||
# CSS can be dynamically set inline, loaded from the same domain, or from \$main_domain
|
||||
set \$styleSrc "'unsafe-inline' 'self' \${main_domain}";
|
||||
|
||||
# connect-src restricts URLs which can be loaded using script interfaces
|
||||
set \$connectSrc "'self' https://\${main_domain} \${main_domain} https://\${api_domain} blob: wss://\${api_domain} \${api_domain} \${files_domain}";
|
||||
set \$connectSrc "'self' https://\${main_domain} \${main_domain} https://\${api_domain} blob: wss://\${api_domain} \${api_domain} \${files_domain} https://\${sandbox_domain}";
|
||||
|
||||
# fonts can be loaded from data-URLs or the main domain
|
||||
set \$fontSrc "'self' data: \${main_domain}";
|
||||
@ -208,11 +238,19 @@ server {
|
||||
set \$unsafe 0;
|
||||
# the following assets are loaded via the sandbox domain
|
||||
# they unfortunately still require exceptions to the sandboxing to work correctly.
|
||||
if (\$uri = "/sheet/inner.html") { set \$unsafe 1; }
|
||||
if (\$uri ~ ^\/common\/onlyoffice\/.*\/index\.html.*\$) { set \$unsafe 1; }
|
||||
if (\$uri ~ ^\/(sheet|doc|presentation)\/inner.html.*\$) { set \$unsafe 1; }
|
||||
if (\$uri ~ ^\/common\/onlyoffice\/.*\/.*\.html.*\$) { set \$unsafe 1; }
|
||||
|
||||
# everything except the sandbox domain is a privileged scope, as they might be used to handle keys
|
||||
if (\$host != \$sandbox_domain) { set \$unsafe 0; }
|
||||
# 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; }
|
||||
EOF
|
||||
|
||||
cat <<EOF >> /etc/nginx/sites-available/${vhost_config_file}
|
||||
|
||||
# privileged contexts allow a few more rights than unprivileged contexts, though limits are still applied
|
||||
if (\$unsafe) {
|
||||
@ -251,11 +289,18 @@ server {
|
||||
# /api/config is loaded once per page load and is used to retrieve
|
||||
# the caching variable which is applied to every other resource
|
||||
# which is loaded during that session.
|
||||
location = /api/config {
|
||||
location ~ ^/api/(config|broadcast).*\$ {
|
||||
proxy_pass http://localhost:3000;
|
||||
proxy_set_header X-Real-IP \$remote_addr;
|
||||
proxy_set_header Host \$host;
|
||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||
|
||||
# These settings prevent both NGINX and the API server
|
||||
# from setting the same headers and creating duplicates
|
||||
proxy_hide_header Cross-Origin-Resource-Policy;
|
||||
add_header Cross-Origin-Resource-Policy cross-origin;
|
||||
proxy_hide_header Cross-Origin-Embedder-Policy;
|
||||
add_header Cross-Origin-Embedder-Policy require-corp;
|
||||
}
|
||||
|
||||
# encrypted blobs are immutable and are thus cached for a year
|
||||
@ -276,6 +321,9 @@ server {
|
||||
add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Content-Length';
|
||||
try_files \$uri =404;
|
||||
}
|
||||
EOF
|
||||
|
||||
cat <<EOF >> /etc/nginx/sites-available/${vhost_config_file}
|
||||
|
||||
# the "block-store" serves encrypted payloads containing users' drive keys
|
||||
# these payloads are unlocked via login credentials. They are mutable
|
||||
@ -285,23 +333,28 @@ server {
|
||||
try_files \$uri =404;
|
||||
}
|
||||
|
||||
# This block provides an alternative means of loading content
|
||||
# otherwise only served via websocket. This is solely for debugging purposes,
|
||||
# and is thus not allowed by default.
|
||||
#location ^~ /datastore/ {
|
||||
#add_header Cache-Control max-age=0;
|
||||
#try_files \$uri =404;
|
||||
#}
|
||||
# This block provides an alternative means of loading content
|
||||
# otherwise only served via websocket. This is solely for debugging purposes,
|
||||
# and is thus not allowed by default.
|
||||
#location ^~ /datastore/ {
|
||||
#add_header Cache-Control max-age=0;
|
||||
#try_files \$uri =404;
|
||||
#}
|
||||
|
||||
# The nodejs server has some built-in forwarding rules to prevent
|
||||
# URLs like /pad from resulting in a 404. This simply adds a trailing slash
|
||||
# to a variety of applications.
|
||||
location ~ ^/(register|login|settings|user|pad|drive|poll|slide|code|whiteboard|file|media|profile|contacts|todo|filepicker|debug|kanban|sheet|support|admin|notifications|teams)\$ {
|
||||
rewrite ^(.*)\$ \$1/ redirect;
|
||||
}
|
||||
# The nodejs server has some built-in forwarding rules to prevent
|
||||
# URLs like /pad from resulting in a 404. This simply adds a trailing slash
|
||||
# to a variety of applications.
|
||||
location ~ ^/(register|login|settings|user|pad|drive|poll|slide|code|whiteboard|file|media|profile|contacts|todo|filepicker|debug|kanban|sheet|support|admin|notifications|teams|calendar|presentation|doc|form|report|convert)\$ {
|
||||
rewrite ^(.*)\$ \$1/ redirect;
|
||||
}
|
||||
|
||||
# Finally, serve anything the above exceptions don't govern.
|
||||
try_files /www/\$uri /www/\$uri/index.html /customize/\$uri;
|
||||
# Finally, serve anything the above exceptions don't govern.
|
||||
try_files /www/\$uri /www/\$uri/index.html /customize/\$uri;
|
||||
|
||||
# Only authenticated users
|
||||
#
|
||||
#auth_basic "\$auth_type";
|
||||
#auth_basic_user_file /etc/nginx/.htpasswd-${cryptpad_url%%.*};
|
||||
}
|
||||
EOF
|
||||
|
||||
@ -389,19 +442,14 @@ npm -v
|
||||
npm install -g bower
|
||||
|
||||
|
||||
# ---
|
||||
# - Create the user for the service:
|
||||
# ---
|
||||
mkdir /var/www/cryptpad
|
||||
chown www-data:www-data /var/www/cryptpad
|
||||
|
||||
|
||||
|
||||
# ---
|
||||
# - Install cryptpad
|
||||
# ---
|
||||
|
||||
cd /var/www/cryptpad
|
||||
chown www-data:www-data /var/www
|
||||
|
||||
cd /var/www
|
||||
|
||||
# - Get cryptpad
|
||||
# -
|
||||
@ -435,22 +483,30 @@ cp -a config/config.example.js config/config.js
|
||||
# - ...
|
||||
# - myDomain: oopen.de,
|
||||
# -
|
||||
perl -i -n -p -e"s#(\s*)(adminEmail:.*)#\1// \2\n\1adminEmail: 'admin\@oopen.de',#" /var/www/cryptpad/cryptpad/config/config.js
|
||||
if $(grep -q -E "\s*/?/?\s*adminEmail" /var/www/cryptpad/config/config.js 2> /dev/null) ; then
|
||||
perl -i -n -p -e"s#(\s*)(adminEmail:.*)#\1// \2\n\1adminEmail: 'admin\@oopen.de',#" /var/www/cryptpad/config/config.js
|
||||
else
|
||||
perl -i -n -p -e"s/(\s*})/ adminEmail: 'admin\@oopen.de',\n\1/" /var/www/cryptpad/config/config.js
|
||||
fi
|
||||
|
||||
perl -i -n -p -e"s#(\s*)(httpUnsafeOrigin:.*)#\1// \2\n\1httpUnsafeOrigin: 'https://${cryptpad_url}',#" /var/www/cryptpad/cryptpad/config/config.js
|
||||
perl -i -n -p -e"s#(\s*)(httpUnsafeOrigin:.*)#\1// \2\n\1httpUnsafeOrigin: 'https://${cryptpad_url}',#" /var/www/cryptpad/config/config.js
|
||||
|
||||
perl -i -n -p -e"s#(\s*)(/*\s*)(httpSafeOrigin:.*)#\1// \3\n\1httpSafeOrigin: 'https://${cryptpad_sandbox_url}',#" /var/www/cryptpad/cryptpad/config/config.js
|
||||
perl -i -n -p -e"s#(\s*)(/*\s*)(httpSafeOrigin:.*)#\1// \3\n\1httpSafeOrigin: 'https://${cryptpad_sandbox_url}',#" /var/www/cryptpad/config/config.js
|
||||
|
||||
|
||||
perl -i -n -p -e"s#(\s*)(/*\s*)(httpAddress:.*)#\1// \3\n\1httpAddress: '::',#" /var/www/cryptpad/cryptpad/config/config.js
|
||||
perl -i -n -p -e"s#(\s*)(/*\s*)(httpAddress:.*)#\1// \3\n\1httpAddress: '::',#" /var/www/cryptpad/config/config.js
|
||||
|
||||
# - deaktivate donate Button
|
||||
# -
|
||||
perl -i -n -p -e"s#(\s*)(/*\s*)(removeDonateButton:.*)#\1//\3\n\1removeDonateButton: true,#" /var/www/cryptpad/cryptpad/config/config.js
|
||||
if $(grep -q -E "\s*/?/?\s*removeDonateButton" /var/www/cryptpad/config/config.js 2> /dev/null) ; then
|
||||
perl -i -n -p -e"s#(\s*)(/*\s*)(removeDonateButton:.*)#\1//\3\n\1removeDonateButton: true,#" /var/www/cryptpad/config/config.js
|
||||
else
|
||||
perl -i -n -p -e"s/(\s*})/ removeDonateButton: true,\n\1/" /var/www/cryptpad/config/config.js
|
||||
fi
|
||||
|
||||
# - Set storage..
|
||||
# -
|
||||
perl -i -n -p -e"s#(\s*)(/*\s*)(defaultStorageLimit:.*)#\1//\3\n\1defaultStorageLimit: 250 * 1024 * 1024,#" /var/www/cryptpad/cryptpad/config/config.js
|
||||
perl -i -n -p -e"s#(\s*)(/*\s*)(defaultStorageLimit:.*)#\1//\3\n\1defaultStorageLimit: 250 * 1024 * 1024,#" /var/www/cryptpad/config/config.js
|
||||
|
||||
# - Customizing CryptPad
|
||||
# -
|
||||
@ -466,12 +522,14 @@ perl -i -n -p -e"s#(\s*)(/*\s*)(defaultStorageLimit:.*)#\1//\3\n\1defaultStorage
|
||||
# - '/customize.dist/' to '/customize' and then edit it there, this way you will
|
||||
# - still be able to pull from (and make pull requests to (!) the git repository.
|
||||
# -
|
||||
cp -a /var/www/cryptpad/cryptpad/customize.dist /var/www/cryptpad/cryptpad/customize
|
||||
cp -a /var/www/cryptpad/customize.dist /var/www/cryptpad/customize
|
||||
|
||||
# - Copy 'favicon.ico' to '/var/www/cryptpad/customize/main-favicon.png'
|
||||
# -
|
||||
cp ~chris/favicon.ico /var/www/cryptpad/cryptpad/customize/main-favicon.png
|
||||
cp ~chris/favicon.ico /var/www/cryptpad/cryptpad/customize.dist
|
||||
cp ~chris/favicon.ico /var/www/cryptpad/customize/main-favicon.png
|
||||
cp ~chris/favicon.ico /var/www/cryptpad/customize.dist
|
||||
chown www-data:www-data /var/www/cryptpad/customize/main-favicon.png
|
||||
chown www-data:www-data /var/www/cryptpad/customize.dist/favicon.ico
|
||||
|
||||
|
||||
|
||||
@ -491,10 +549,10 @@ Requires=nginx.service
|
||||
Type=simple
|
||||
User=www-data
|
||||
Group=www-data
|
||||
Environment='PWD="/var/www/cryptpad/cryptpad"'
|
||||
Environment='PWD="/var/www/cryptpad"'
|
||||
# modify to match the location of your cryptpad repository
|
||||
WorkingDirectory=/var/www/cryptpad/cryptpad
|
||||
ExecStart=/usr/bin/node /var/www/cryptpad/cryptpad/server.js
|
||||
WorkingDirectory=/var/www/cryptpad
|
||||
ExecStart=/usr/bin/node /var/www/cryptpad/server.js
|
||||
|
||||
TimeoutSec=30
|
||||
# Restart service after 10 seconds if node service crashes
|
||||
@ -524,3 +582,12 @@ systemctl enable cryptpad
|
||||
# -
|
||||
systemctl start cryptpad
|
||||
|
||||
|
||||
# ---
|
||||
# Basic Check of your configuration:
|
||||
# ---
|
||||
|
||||
# In yout browser type:
|
||||
#
|
||||
# https://${cryptpad_url}/checkup/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user