官方说明:
一、容器端口、目录卷映射
sudo docker run --name=容器名称 --restart=always -i -t -d -p 443:443 -v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data onlyoffice/documentserver
这里需要映射【443】端口,并且映射docker的/var/www/onlyoffice/Data目录,用于存放ssl证书。
二、ssl证书配置
将 onlyoffice.key 和 onlyoffice.crt 格式的证书放到【宿主机】的/app/onlyoffice/DocumentServer/data/certs/目录下,因为刚才映射过了,注意证书文件名称一定是 onlyoffice.key 和 onlyoffice.crt ,否则启动报错,或者进入docker容器中,将nginx的配置文件的证书名称改掉。
三、重启docker容器
sudo docker restart 容器名称
四、如果报错 the document could not be saved
the document could not be saved,please check connection settings or concat your administrator.
查看下容器日志:
[2023-11-15T11:42:30.934] [ERROR] [localhost] [192.168.101.26new__1_.xlsx1700048549299] [uid-1] nodeJS - postData error: url = https://192.168.101.111/example/track?filename=new%20(1).xlsx&useraddress=192.168.101.26;data = {"key":"192.168.101.26new__1_.xlsx1700048549299","status":1,"users":["uid-1"],"actions":[{"type":1,"userid":"uid-1"}],"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiIxOTIuMTY4LjEwMS4yNm5ld19fMV8ueGxzeDE3MDAwNDg1NDkyOTkiLCJzdGF0dXMiOjEsInVzZXJzIjpbInVpZC0xIl0sImFjdGlvbnMiOlt7InR5cGUiOjEsInVzZXJpZCI6InVpZC0xIn1dLCJpYXQiOjE3MDAwNDg1NTAsImV4cCI6MTcwMDA0ODg1MH0.o1kkVun-SGl3MgM-SoPsGn_Rbw3-SagZQvneoZ8ENpM"}
Error: self signed certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1515:34)
at TLSSocket.emit (events.js:400:28)
at TLSSocket._finishInit (_tls_wrap.js:937:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:709:12)
可以看到报错原因是:Error: self signed certificate
解决方案:
将/etc/onlyoffice/documentserver/default.json文件中的rejectUnauthorized字段值改为false
然后,重启容器