diff --git a/conf/nginx.conf b/conf/nginx.conf index f3e1778..99f8a79 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -5,6 +5,7 @@ set $api_domain "__DOMAIN__"; set $files_domain "__DOMAIN__"; ssl_ecdh_curve secp384r1; more_set_headers "Access-Control-Allow-Origin: '${allowed_origins}'"; +more_set_headers "'Access-Control-Allow-Credentials' true"; more_set_headers "Cross-Origin-Resource-Policy: cross-origin"; more_set_headers "Cross-Origin-Embedder-Policy: require-corp"; root __INSTALL_DIR__/; @@ -32,9 +33,17 @@ if ($uri ~ ^\/(sheet|doc|presentation)\/inner.html.*$) { set $unsafe 1; } if ($uri ~ ^\/common\/onlyoffice\/.*\/.*\.html.*$) { set $unsafe 1; } if ($host != $sandbox_domain) { set $unsafe 0; } if ($uri ~ ^\/unsafeiframe\/inner\.html.*$) { set $unsafe 1; } + +# draw.io uses inline script tags in it's index.html. The hashes are added here. +if ($uri ~ ^\/components\/drawio\/src\/main\/webapp\/index.html.*$) { + set $scriptSrc "'self' 'sha256-6zAB96lsBZREqf0sT44BhH1T69sm7HrN34rpMOcWbNo=' 'sha256-6g514VrT/cZFZltSaKxIVNFF46+MFaTSDTPB8WfYK+c=' resource: https://${main_domain}"; +} + +# privileged contexts allow a few more rights than unprivileged contexts, though limits are still applied if ($unsafe) { set $scriptSrc "'self' 'unsafe-eval' 'unsafe-inline' resource: https://${main_domain}"; } + more_set_headers "Content-Security-Policy: default-src 'none'; child-src $childSrc; worker-src $workerSrc; media-src $mediaSrc; style-src $styleSrc; script-src $scriptSrc; connect-src $connectSrc; font-src $fontSrc; img-src $imgSrc; frame-src $frameSrc; frame-ancestors $frameAncestors"; location ^~ /cryptpad_websocket { proxy_pass http://127.0.0.1:__PORT__; @@ -62,9 +71,10 @@ location ~ ^/api/.*$ { proxy_hide_header Cross-Origin-Embedder-Policy; more_set_headers "Cross-Origin-Embedder-Policy: require-corp"; } -location ^~ /blob/ { +location ~ ^/(blob|block)/.*$ { if ($request_method = 'OPTIONS') { more_set_headers "Access-Control-Allow-Origin: ${allowed_origins}"; + more_set_headers "'Access-Control-Allow-Credentials' true"; more_set_headers "Access-Control-Allow-Methods: 'GET, POST, OPTIONS'"; more_set_headers "Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range"; more_set_headers "Access-Control-Max-Age: 1728000"; @@ -81,11 +91,13 @@ location ^~ /blob/ { try_files $uri =404; } location ^~ /block/ { - more_set_headers "X-Content-Type-Options: nosniff"; - more_set_headers "Cache-Control: max-age=0"; - try_files $uri =404; + proxy_hide_header 'X-Content-Type-Options'; + proxy_hide_header 'Access-Control-Allow-Origin'; + proxy_hide_header 'Permissions-Policy'; + proxy_hide_header 'X-XSS-Protection'; + proxy_pass http://127.0.0.1:3000; } -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|checkup)$ { +location ~ ^/(register|login|recovery|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|checkup|diagram)$ { rewrite ^(.*)$ $1/ redirect; } try_files /customize/www/$uri /customize/www/$uri/index.html /www/$uri /www/$uri/index.html /customize/$uri; diff --git a/manifest.toml b/manifest.toml index 8e916b8..3eb79c8 100644 --- a/manifest.toml +++ b/manifest.toml @@ -50,7 +50,7 @@ ram.runtime = "50M" autoupdate.strategy = "latest_github_tag" [resources.ports] - main.default = 3000 + main.default = 3003 porti.default = 3001 [resources.system_user]