mirror of
https://github.com/YunoHost-Apps/cryptpad_ynh.git
synced 2024-09-03 18:26:14 +02:00
Update nginx.conf
This commit is contained in:
parent
71e2d2591a
commit
2333da82a7
1 changed files with 93 additions and 18 deletions
111
conf/nginx.conf
111
conf/nginx.conf
|
@ -1,19 +1,94 @@
|
||||||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
set $main_domain "__DOMAIN__";
|
||||||
location __PATH__/ {
|
set $sandbox_domain "sandbox-__DOMAIN__";
|
||||||
|
set $allowed_origins "https://${sandbox_domain}";
|
||||||
proxy_pass http://127.0.0.1:__PORT__;
|
set $api_domain "api.__DOMAIN__";
|
||||||
proxy_redirect off;
|
set $files_domain "files.__DOMAIN__";
|
||||||
proxy_set_header Host $host;
|
ssl_ecdh_curve secp384r1;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
add_header X-XSS-Protection "1; mode=block";
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
add_header X-Content-Type-Options nosniff;
|
||||||
proxy_set_header X-Forwarded-Host $server_name;
|
add_header Access-Control-Allow-Origin "${allowed_origins}";
|
||||||
|
add_header Cross-Origin-Resource-Policy cross-origin;
|
||||||
proxy_http_version 1.1;
|
add_header Cross-Origin-Embedder-Policy require-corp;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
root /var/www/cryptpad;
|
||||||
proxy_set_header Connection "upgrade";
|
index index.html;
|
||||||
|
error_page 404 /customize.dist/404.html;
|
||||||
# Include SSOWAT user panel.
|
if ($uri ~ ^(\/|.*\/|.*\.html)$) {
|
||||||
include conf.d/yunohost_panel.conf.inc;
|
set $cacheControl no-cache;
|
||||||
more_clear_input_headers 'Accept-Encoding';
|
|
||||||
}
|
}
|
||||||
|
if ($args ~ ver=) {
|
||||||
|
set $cacheControl max-age=31536000;
|
||||||
|
}
|
||||||
|
add_header Cache-Control $cacheControl;
|
||||||
|
set $styleSrc "'unsafe-inline' 'self' https://${main_domain}";
|
||||||
|
set $connectSrc "'self' https://${main_domain} blob: wss://${api_domain} https://${sandbox_domain}";
|
||||||
|
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}";
|
||||||
|
}
|
||||||
|
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; frame-ancestors $frameAncestors";
|
||||||
|
location ^~ /cryptpad_websocket {
|
||||||
|
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;
|
||||||
|
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/.*$ {
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
location ^~ /blob/ {
|
||||||
|
if ($request_method = 'OPTIONS') {
|
||||||
|
add_header 'Access-Control-Allow-Origin' "${allowed_origins}";
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
|
||||||
|
add_header 'Access-Control-Max-Age' 1728000;
|
||||||
|
add_header 'Content-Type' 'application/octet-stream; charset=utf-8';
|
||||||
|
add_header 'Content-Length' 0;
|
||||||
|
return 204;
|
||||||
|
}
|
||||||
|
add_header X-Content-Type-Options nosniff;
|
||||||
|
add_header Cache-Control max-age=31536000;
|
||||||
|
add_header 'Access-Control-Allow-Origin' "${allowed_origins}";
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||||
|
add_header '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';
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
location ^~ /block/ {
|
||||||
|
add_header X-Content-Type-Options nosniff;
|
||||||
|
add_header 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;
|
||||||
|
|
Loading…
Add table
Reference in a new issue