如何修复 NextCloud OnlyOffice MixedContent 或 'Refused to frame http://... because it violates Content Security Policy directive frame-src https://...'

问题:

在转发请求到 OnlyOffice 的反向代理设置中,如我们的参考设置,你可能会遇到类似这样的问题

onlyoffice_frame_error.txt
Refused to frame 'http://onlyoffice.mydomain.com/' because it violates the following Content Security Policy directive: "frame-src https://onlyoffice.mydomain.com/".

解决方案

只需添加

onlyoffice-proxy.conf
proxy_set_header X-Forwarded-Proto $scheme;

在你的 nginx 配置中的 proxy_pass 子句之后,然后运行 sudo service nginx reload

此问题的原因是 OnlyOffice 认为它正在使用 HTTP 加载,但 Nextcloud 页面阻止加载不安全的内容。

使用 nginx 以外的代理?只需确保每个代理请求(即每个指向 OnlyOffice 实例的请求)的 X-Forwarded-Proto 头设置为原始请求的协议 - 应该是 https


Check out similar posts by category: Nextcloud, Nginx