> ## Content Index
> Fetch the complete content index at: https://lucent.blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# 记录使用NextCloud连接OnlyOffice时遇到的问题
- URL: https://lucent.blog/ji-lu-shi-yong-nextcloudlian-jie-onlyofficeshi-yu-dao-de-wen-ti/
- Published: 2021-11-23T04:43:18.000Z
- Updated: 2026-08-21T00:49:57.000Z
- Author: Lucent

### 问题

在NextCloud后台设置连接OnlyOffice时一切正常，并且域名为https，  
NextCloud域名和OnlyOffice域名均使用nginx代理（使用了宝塔，方便管理），OnlyOffice只对外映射了80端口，证书使用了nginx配置，但是在打开文档时会报错：

```javascript
Refused to frame 'http://office.xxx.com' because itviolates the following Content Security Policy directive: "frame-src 'self' https://demo.ja.collaboraonline.com https://office.xxx.com/"

```

![sada](https://img-1251540275.cos.ap-shanghai.myqcloud.com/uPic/sada.png)

### 原因

OnlyOffice内部不够智能，不能自动升级https请求

### 解决方案

以下方案对我有效：

#### 1.修改NextCloud配置

修改NextCloud根目录/config下的config.php文件  
在最下面加上

```php
'allow_local_remote_servers' => true

```

![image.png](https://img-1251540275.cos.ap-shanghai.myqcloud.com/blog/image_1637643194601.png)

#### 2.修改OnlyOffice的Nginx的反向代理配置

直接把反向代理的配置替换成如下代码(自行修改ip和端口)：

```shell
location /
{
    proxy_pass http://10.0.12.5:30010;
		proxy_set_header Host $host:443;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
}

	location ~ /websocket$ {
		proxy_pass http://10.0.12.5:30010;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
                proxy_set_header Host $host:443;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;

	}

```

![image.png](https://img-1251540275.cos.ap-shanghai.myqcloud.com/blog/image_1637643448207.png)

  
这样就成功了:  

![image.png](https://img-1251540275.cos.ap-shanghai.myqcloud.com/blog/image_1637643547033.png)

网络上其他的解决办法是给页面头部加上：

```html
<meta charset="utf-8" http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">

```

但是这样对我的问题无效。