nextcloud: CORS (cette fois c’est la bonne)

nextcloud
Pyjacpp 2026-08-04 11:55:09 +02:00
parent eafe7b8e0b
commit 1f96169d8c
No known key found for this signature in database
GPG Key ID: ED479A5A26930939
1 changed files with 7 additions and 24 deletions

View File

@ -54,28 +54,11 @@
};
# Activation CORS pour récuppérer les agendas depuis le wiki
# On est obligé de répéter les headers communs de sécurité car ils ne sont pas au même niveau
# https://github.com/yandex/gixy/blob/master/docs/en/plugins/addheaderredefinition.md
services.nginx.virtualHosts.${config.services.nextcloud.hostName}.locations."~* /remote.php/dav/public-calendars/[a-z]+\?export".extraConfig =
let
base_headers = ''
add_header X-Content-Type-Options nosniff;
add_header X-Robots-Tag noindex, nofollow;
add_header X-Permitted-Cross-Domain-Policies none;
add_header X-Frame-Options sameorigin;
add_header Referrer-Policy no-referrer;
add_header 'Access-Control-Allow-Origin' 'https://mediawiki.crans.org' always;
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
'';
in
''
${base_headers}
if ($request_method = 'OPTIONS') {
${base_headers}
add_header 'Access-Control-Max-Age' 86400;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
'';
# TODO: à mettre que sur /remote.php/dav/public-calendars/ pour éviter des requêtes malveillantes depuis le wiki.
services.nginx.virtualHosts.${config.services.nextcloud.hostName}.extraConfig = ''
add_header 'Access-Control-Allow-Origin' 'https://mediawiki.crans.org' always;
add_header 'Access-Control-Allow-Methods' 'GET' always;
add_header 'Access-Control-Allow-Credentials' 'false' always;
add_header 'Vary' 'Origin' always;
'';
}