OnlyOffice打开文档提示“这份文件无法保存”解决方法


#1

Seafile社区版部署在127.0.0.1:58000,通过nginx发布服务,集成了docker方式部署OnlyOffice,但打开Office文档提示“这份文件无法保存”,点击确认跳转api.onlyoffice.com/editors/callback。

最近空了看下日志,OnlyOffice在docker中/app/onlyoffice/DocumentServer/logs/documentserver/docservice/out.log发现
[2020-10-09T07:10:45.152] [ERROR] nodeJS - sendServerRequest error: docId = 9c9a781ddb58737b5c80;url = https://xxx.net/onlyoffice/editor-callback/;data = {“key”:“9c9a781ddb58737b5c80”,“status”:2,“url”:"…",“history”:{…}
Error: Error response: statusCode:401 ;body:

错误是OnlyOffice访问https://xxx.net/onlyoffice/editor-callback/时,报错401需要http验证。

我的seafile是通过nginx部署的,nginx同站点下还有其他网站,并且需要http验证,所以对于seafile只在nginx中配置了
location / {
proxy_pass http://127.0.0.1:58000;
#proxy_set_header Host $host:$server_port;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto https;
proxy_read_timeout 1200s;
client_max_body_size 0;
}

            location /seafhttp {
                    rewrite ^/seafhttp(.*)$ $1 break;
                    proxy_pass http://127.0.0.1:8082;
                    client_max_body_size 0;
                    proxy_connect_timeout 36000s;
                    proxy_read_timeout 36000s;
            }

测试访问https://xxx.net/onlyoffice/editor-callback确实也是401错误,原因是/onlyoffice路径下的访问被发送到了非seafile服务端处理,于是仿照/添加一组配置
location /onlyoffice {
proxy_pass http://127.0.0.1:58000;
#proxy_set_header Host $host:$server_port;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto https;
proxy_read_timeout 1200s;
client_max_body_size 0;
}

测试访问https://xxx.net/onlyoffice/editor-callback返回{“error”: 0},不再是401错误

从seafile中打开文档也不在有上述提示,问题解决!


#2

[root@9e99618414e3 conf]# cat seahub_settings.py

-- coding: utf-8 --

SECRET_KEY = “b’7bfadl59ws2b&pz_+!llzba!226nb+lfu=wj(-vve-)e5ly)mk’”
#onlyoffice
ENABLE_ONLYOFFICE = True
VERIFY_ONLYOFFICE_CERTIFICATE = False
ONLYOFFICE_APIJS_URL = ‘http://你的IP:8080/web-apps/apps/api/documents/api.js
ONLYOFFICE_FILE_EXTENSION = (‘doc’, ‘docx’, ‘ppt’, ‘pptx’, ‘xls’, ‘xlsx’, ‘odt’, ‘fodt’, ‘odp’, ‘fodp’, ‘ods’, ‘fods’)
ONLYOFFICE_EDIT_FILE_EXTENSION = (‘docx’, ‘pptx’, ‘xlsx’)