2022-12-09 18:01:27 +01:00
|
|
|
set $main_domain "__DOMAIN__";
|
2023-02-09 16:29:58 +01:00
|
|
|
set $sandbox_domain "__SANDBOXDOMAIN__";
|
2022-12-09 18:01:27 +01:00
|
|
|
set $allowed_origins "https://${sandbox_domain}";
|
|
|
|
set $api_domain "__DOMAIN__";
|
|
|
|
set $files_domain "__DOMAIN__";
|
|
|
|
ssl_ecdh_curve secp384r1;
|
|
|
|
more_set_headers "Access-Control-Allow-Origin: '${allowed_origins}'";
|
|
|
|
more_set_headers "Cross-Origin-Resource-Policy: cross-origin";
|
|
|
|
more_set_headers "Cross-Origin-Embedder-Policy: require-corp";
|
2023-03-12 08:24:05 +01:00
|
|
|
root __INSTALL_DIR__/;
|
2022-12-09 18:01:27 +01:00
|
|
|
index index.html;
|
|
|
|
error_page 404 /customize.dist/404.html;
|
|
|
|
if ($uri ~ ^(\/|.*\/|.*\.html)$) {
|
|
|
|
set $cacheControl no-cache;
|
2017-07-04 01:19:07 +02:00
|
|
|
}
|
2022-12-09 18:01:27 +01:00
|
|
|
if ($args ~ ver=) {
|
|
|
|
set $cacheControl max-age=31536000;
|
|
|
|
}
|
|
|
|
more_set_headers "Cache-Control: $cacheControl";
|
|
|
|
set $styleSrc "'unsafe-inline' 'self' https://${main_domain}";
|
2023-03-24 08:27:18 +01:00
|
|
|
set $connectSrc "'self' https://${main_domain} blob: wss://${api_domain} https://${sandbox_domain}";
|
2022-12-09 18:01:27 +01:00
|
|
|
set $fontSrc "'self' data: https://${main_domain}";
|
|
|
|
set $imgSrc "'self' data: blob: https://${main_domain}";
|
|
|
|
set $frameSrc "'self' https://${sandbox_domain} blob:";
|
|
|
|
set $mediaSrc "blob:";
|
|
|
|
set $childSrc "https://${main_domain}";
|
|
|
|
set $workerSrc "'self'";
|
|
|
|
set $scriptSrc "'self' resource: https://${main_domain}";
|
|
|
|
set $frameAncestors "'self' https://${main_domain}";
|
|
|
|
set $unsafe 0;
|
|
|
|
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; }
|
|
|
|
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 {
|
2023-02-15 21:42:31 +01:00
|
|
|
proxy_pass http://127.0.0.1:__PORT__;
|
2022-12-09 18:01:27 +01:00
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection upgrade;
|
|
|
|
}
|
|
|
|
location ^~ /customize.dist/ {
|
|
|
|
# This is needed in order to prevent infinite recursion between /customize/ and the root
|
|
|
|
}
|
|
|
|
location ^~ /customize/ {
|
|
|
|
rewrite ^/customize/(.*)$ $1 break;
|
|
|
|
try_files /customize/$uri /customize.dist/$uri;
|
|
|
|
}
|
|
|
|
location ~ ^/api/.*$ {
|
2023-02-15 21:42:38 +01:00
|
|
|
proxy_pass http://127.0.0.1:__PORT__;
|
2022-12-09 18:01:27 +01:00
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_hide_header Cross-Origin-Resource-Policy;
|
|
|
|
more_set_headers "Cross-Origin-Resource-Policy: cross-origin";
|
|
|
|
proxy_hide_header Cross-Origin-Embedder-Policy;
|
|
|
|
more_set_headers "Cross-Origin-Embedder-Policy: require-corp";
|
|
|
|
}
|
|
|
|
location ^~ /blob/ {
|
|
|
|
if ($request_method = 'OPTIONS') {
|
2023-03-24 09:35:15 +01:00
|
|
|
more_set_headers "Access-Control-Allow-Origin: ${allowed_origins}";
|
2022-12-09 18:01:27 +01:00
|
|
|
more_set_headers "Access-Control-Allow-Methods: 'GET, POST, OPTIONS'";
|
2023-03-24 09:35:15 +01:00
|
|
|
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";
|
2022-12-09 18:01:27 +01:00
|
|
|
more_set_headers "Access-Control-Max-Age: 1728000";
|
|
|
|
more_set_headers "Content-Type: 'application/octet-stream; charset=utf-8'";
|
|
|
|
more_set_headers "Content-Length: 0";
|
|
|
|
return 204;
|
|
|
|
}
|
|
|
|
more_set_headers "X-Content-Type-Options: nosniff";
|
|
|
|
more_set_headers "Cache-Control: max-age=31536000'";
|
2023-03-24 09:35:15 +01:00
|
|
|
more_set_headers "Access-Control-Allow-Origin: ${allowed_origins}";
|
2022-12-09 18:01:27 +01:00
|
|
|
more_set_headers "Access-Control-Allow-Methods: 'GET, POST, OPTIONS'";
|
2023-03-24 09:35:15 +01:00
|
|
|
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,Content-Length";
|
|
|
|
more_set_headers "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";
|
2022-12-09 18:01:27 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
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)$ {
|
|
|
|
rewrite ^(.*)$ $1/ redirect;
|
|
|
|
}
|
|
|
|
try_files /customize/www/$uri /customize/www/$uri/index.html /www/$uri /www/$uri/index.html /customize/$uri;
|