WIP nginx config refactor

pull/1/head
ansuz 5 years ago
parent 1da662687f
commit c56815fa3b

@ -6,7 +6,16 @@
server { server {
listen 443 ssl http2; listen 443 ssl http2;
server_name your-main-domain.com your-sandbox-domain.com;
# XXX These two variables
set $main_domain "your-main-domain.com";
set $sandbox_domain "your-sandbox-domain.com";
# The $api_domain and $files_domain are optional
set $api_domain "api.your-main-domain.com";
set $files_domain "files.your-main-domain.com";
server_name $main_domain $sandbox_domain;
ssl_certificate /home/cryptpad/.acme.sh/your-main-domain.com/fullchain.cer; ssl_certificate /home/cryptpad/.acme.sh/your-main-domain.com/fullchain.cer;
ssl_certificate_key /home/cryptpad/.acme.sh/your-main-domain.com/your-main-domain.com.key; ssl_certificate_key /home/cryptpad/.acme.sh/your-main-domain.com/your-main-domain.com.key;
@ -24,6 +33,7 @@ server {
add_header X-Content-Type-Options nosniff; add_header X-Content-Type-Options nosniff;
# add_header X-Frame-Options "SAMEORIGIN"; # add_header X-Frame-Options "SAMEORIGIN";
# Insert the path to your CryptPad repository root here
root /home/cryptpad/cryptpad; root /home/cryptpad/cryptpad;
index index.html; index index.html;
error_page 404 /customize.dist/404.html; error_page 404 /customize.dist/404.html;
@ -34,15 +44,15 @@ server {
# Will not set any header if it is emptystring # Will not set any header if it is emptystring
add_header Cache-Control $cacheControl; add_header Cache-Control $cacheControl;
set $styleSrc "'unsafe-inline' 'self' your-main-domain.com"; set $styleSrc "'unsafe-inline' 'self' ${main_domain}";
set $scriptSrc "'self' your-main-domain.com"; set $scriptSrc "'self' ${main_domain}";
set $connectSrc "'self' https://your-main-domain.com wss://your-main-domain.com your-main-domain.com https://api.your-main-domain.com blob: your-main-domain.com"; set $connectSrc "'self' https://${main_domain} wss://${main_domain} $main_domain https://${api_domain} blob:";
set $fontSrc "'self' data: your-main-domain.com"; set $fontSrc "'self' data: ${main_domain}";
set $imgSrc "'self' data: * blob: your-main-domain.com"; set $imgSrc "'self' data: * blob: ${main_domain}";
set $frameSrc "'self' your-sandbox-domain.com blob: your-sandbox-domain.com"; set $frameSrc "'self' ${sandbox_domain} blob:";
set $mediaSrc "'self' data: * blob: your-main-domain.com"; set $mediaSrc "'self' data: * blob: ${main_domain}";
set $childSrc "https://your-main-domain.com"; set $childSrc "https://${main_domain}";
set $workerSrc "https://your-main-domain.com"; set $workerSrc "https://${main_domain}";
set $unsafe 0; set $unsafe 0;
if ($uri = "/pad/inner.html") { set $unsafe 1; } if ($uri = "/pad/inner.html") { set $unsafe 1; }
@ -50,7 +60,7 @@ server {
if ($uri = "/common/onlyoffice/web-apps/apps/spreadsheeteditor/main/index.html") { set $unsafe 1; } if ($uri = "/common/onlyoffice/web-apps/apps/spreadsheeteditor/main/index.html") { set $unsafe 1; }
if ($host != sandbox.cryptpad.info) { set $unsafe 0; } if ($host != sandbox.cryptpad.info) { set $unsafe 0; }
if ($unsafe) { if ($unsafe) {
set $scriptSrc "'self' 'unsafe-eval' 'unsafe-inline' new2.cryptpad.fr cryptpad.fr"; set $scriptSrc "'self' 'unsafe-eval' 'unsafe-inline' ${main_domain}";
} }
add_header 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;"; add_header 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;";

Loading…
Cancel
Save