原文链接:https://dsx2016.com/?p=1778
公众号:大师兄2016
配置文件
docker-compose.yml
version: "3"
services:
service.onlyoffice:
image: onlyoffice/documentserver
container_name: onlyoffice
ports:
- 9021:80
volumes:
- ./logs:/var/log/onlyoffice
- ./data:/var/www/onlyoffice/Data
- ./lib:/var/lib/onlyoffice
- ./db:/var/lib/postgresql
restart: always
stdin_open: true
tty: true
运行
docker-compose up -d
访问
IP:端口
看到这个页面说明成功了
关闭安全校验
(非必须)nextcloud中config/config.php文件添加
'onlyoffice' => array (
'verify_peer_off' => true
),
(非必须)受信任域名添加
documentServer为部署onlyOfice的服务器ip或者域名
'trusted_domains' =>
array (
0 => 'documentServer',
),
安装插件
安装onlyOffice插件并启用
填写文档服务器地址
注意事项
-
ip对应ip
-
域名对应域名
-
http对应http
-
https对应https
点击保存弹出提示成功即可
新建文件
完成表格加载
配置ssl证书
官方文档
https://github.com/ONLYOFFICE/Docker-DocumentServer#running-onlyoffice-document-server-using-https
在当前根目录下的data文件夹再新建certs文件
并且把两个证书文件名称都改为tls前缀即可
设置配置文件代理容器的443端口
比如本文的9021指向docker容器的80
9022指向docker容器的443
version: "3"
services:
service.onlyoffice:
image: onlyoffice/documentserver
container_name: onlyoffice
ports:
- 9021:80
- 9022:443
volumes:
- ./logs:/var/log/onlyoffice
- ./data:/var/www/onlyoffice/Data
- ./lib:/var/lib/onlyoffice
- ./db:/var/lib/postgresql
restart: always
stdin_open: true
tty: true
设置nginx
千万注意!!!
千万注意!!!
千万注意!!!
443端口的proxy_pass一定要指向https://ip:端口
而不是http,否则会报400
nginx错误提示The plain HTTP request was sent to HTTPS port
原因是https的域名又代理到docker容器的https,双层代理,不允许有http的请求
所以千万不要写成http,而是proxy_pass https://127.0.0.1:9022;
# 本地的80端口(http服务)
server {
listen 80;
# onlyoffice
server_name onlyoffice.domain.com;
location / {
# root /var/www/html/client; #站点目录
# index index.html index.htm;
# 指向本地的nodejs服务器
proxy_pass http://127.0.0.1:9021;
#设置请求头,并将头信息传递给服务器端
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# 强制跳转https
# rewrite ^(.*)$ https://$host$1 permanent;
}
}
# onlyoffice
server {
listen 443;
# onlyoffice
server_name onlyoffice.domain.com;
ssl on;
# root html;
# index index.html index.htm;
# SSL证书放在了同级目录small文件夹下面
ssl_certificate cert/onlyoffice/1_onlyoffice.domain.com_bundle.crt;
ssl_certificate_key cert/onlyoffice/2_onlyoffice.domain.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
# 指向当前的某个服务端口
proxy_pass https://127.0.0.1:9022;
#设置请求头,并将头信息传递给服务器端
proxy_redirect off;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
记得设置域名解析到云主机
END.