I am running a Nextcloud server with multiple DNS aliases. When users try to open office documents this sometimes fails with the error message “Document loading failed”. In the console I see the following error message:
Hello @uli-a i see there are some configuration issues.
The error occurs because the document is being accessed from https://dns-alias-1.tld, but the form action is trying to submit to https://dns-alias-2.tld.
The CSP rule allows form submissions only to https://dns-alias-2.tld and self, which in this context would mean https://dns-alias-1.tld. However, since self is https://dns-alias-1.tld, but the form is targeting https://dns-alias-2.tld, the browser blocks the request as a security measure.
Why This Happens:
This typically occurs when Nextcloud and Collabora Online are accessed via different DNS aliases, and there is an inconsistency in how they handle or route the requests.
For instance, if a user accesses Nextcloud at https://dns-alias-1.tld and then tries to open a document, the request might be redirected to https://dns-alias-2.tld for the document processing (WOPI) by Collabora Online, triggering the CSP violation.
Update the coolwsd.xml or loolwsd.xml file on your Collabora server to handle multiple DNS aliases properly. Ensure the host settings cover all the aliases you’re using.
Make sure the frame_ancestors directive allows both DNS aliases if they are embedded in iframes.
I am using the build-in CODE server of Nextcloud and did not find the configuration files you mentioned (coolwsd.xml/loolwsd.xml). Is there a way to do this for the build-in server as well?
So In your Nextcloud config.php, you can specify the overwritehost and overwriteprotocol settings to ensure consistent URLs are used, preventing such mismatches.