onlyoffice 是一款自由的办公套件生产力软件和具有协作功能的软件套件。它具有文本文档、电子表格、演示文稿、表格和、PDF、在线编辑器以及基于房间的协作平台。在此分享一次onlyoffice部署经过
shell
复制代码# 拉取镜像
onlyoffice/documentserver:latest
编写docker-compose 配置文件
yaml
复制代码services:
onlyoffice:
image: onlyoffice/documentserver
container_name: onlyoffice
ports:
- 8011:443
- 8012:80
volumes:
- ./onlyoffice/logs:/var/log/onlyoffice
- ./onlyoffice/data:/var/www/onlyoffice/Data
- ./onlyoffice/lib:/var/lib/onlyoffice
- ./onlyoffice/db:/var/lib/postgresql
restart: always
environment:
- JWT_ENABLED=false
启动容器
shell
复制代码docker-compose up -d
配置nginx域名访问
普通代理
配置好站点后添加如下反向代理
conf
复制代码location ^~ /{
proxy_pass http://127.0.0.1:8012/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
add_header X-Cache $upstream_cache_status;
add_header Strict-Transport-Security "max-age=31536000";
add_header Cache-Control no-cache;
}
直接访问https://你的域名/welcome/即可
跨路径代理
即使用https://域名/自定义路径/访问,
修改容器中的nginx 配置文件
修改容器中的
/etc/onlyoffice/documentserver/nginx/includes/ds-docservice.conf
shell
复制代码# 第2-3行
#script caching protection
rewrite ^(?\/web-apps\/apps\/(?!api\/).*)$ $the_scheme://$the_host$the_prefix/onlyoffice/8.0.1-31$cache redirect;
# 第69-71行
# 此处和nginx 配置的子路径保持一致
location ^~ /onlyoffice {
proxy_pass http://docservice;
}
修改后可将容器报保存为镜像、或将配置文件映射到主机进行修改方便后续使用。
修改域名反向代理
conf
复制代码# onlyoffice 可替换为自己想要的路径
location ^~ /onlyoffice {
proxy_pass http://127.0.0.1:8012/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
add_header X-Cache $upstream_cache_status;
add_header Strict-Transport-Security "max-age=31536000";
add_header Cache-Control no-cache;
}
# 缓存代理
location ^~ /cache/ {
proxy_pass http://localhost:8012/cache/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
add_header X-Cache $upstream_cache_status;
add_header Strict-Transport-Security "max-age=31536000";
add_header Cache-Control no-cache;
}
验证
访问https://域名/onlyoffice/welcome/ 如图:
预览验证
html代码解读复制代码
使用浏览器打开HTML文件即可看到预览成功 如图:
如果这篇文章对你有所帮助,请帮忙点赞分享帮助到更多的人,如果你在安装过程中遇到问题,欢迎在评论区留言或私信交流。