整合 OnlyOffice 就可以在线打开各种办公文档进行编辑。
前言
首先 Seafile pro
版支持多种 Office 在线预览和编辑的方式。
教程
- Seafile 整合 OnlyOffice 官方文档
- 用 Docker 部署 Seafile 专业版
- 用 Docker 部署 OnlyOffice
准备工作
将 OnlyOffice 加入到
将以下内容添加到 docker-compose.yml
的 services
中
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| services: ... oods: image: onlyoffice/documentserver:latest container_name: seafile-oods volumes: - /opt/seafile/oods/DocumentServer/logs:/var/log/onlyoffice - /opt/seafile/oods/DocumentServer/data:/var/www/onlyoffice/Data - /opt/seafile/oods/DocumentServer/lib:/var/lib/onlyoffice - /opt/seafile/oods/DocumentServer/local-production-linux.json:/etc/onlyoffice/documentserver/local-production-linux.json
networks: - seafile-net environment: - JWT_ENABLED=true - JWT_SECRET=your-secret-string
|
并且在 seafile 部分加入一行
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| seafile: image: docker.seadrive.org/seafileltd/seafile-pro-mc:latest container_name: seafile ports: - "127.0.0.1:8000:80" volumes: - /opt/seafile/data:/shared environment: ... depends_on: - db - memcached - elasticsearch - oods networks: - seafile-net
|
初始化 OnlyOffice 配置文件
设置OnlyOffice自动保存
执行以下命令
1 2
| mkdir -p /opt/seafile/oods/DocumentServer/ vim /opt/seafile/oods/DocumentServer/local-production-linux.json
|
并为 local-production-linux.json 添加内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| { "services": { "CoAuthoring": { "autoAssembly": { "enable": true, "interval": "5m" } } }, "FileConverter": { "converter": { "downloadAttemptMaxCount": 1 } } }
|
将 OnlyOffice 加入到 nginx conf 中
修改容器的Nginx文件,而不是宿主机的文件!
1
| vim /opt/seafile/data/nginx/conf/seafile.nginx.conf
|
seafile.nginx.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| map $http_x_forwarded_proto $the_scheme { default $http_x_forwarded_proto; "" $scheme; } map $http_x_forwarded_host $the_host { default $http_x_forwarded_host; "" $host; } map $http_upgrade $proxy_connection { default upgrade; "" close; } server { listen 80; ...
location /onlyofficeds/ { proxy_pass http://oods/; proxy_http_version 1.1; client_max_body_size 100M; proxy_read_timeout 3600s; proxy_connect_timeout 3600s; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $proxy_connection; proxy_set_header X-Forwarded-Host $the_host/onlyofficeds; proxy_set_header X-Forwarded-Proto $the_scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
|
修改 seahub_settings.py
seahub_settings.py
1
| vim /opt/seafile/data/seafile/conf/seahub_settings.py
|
在最后面加入下面内容
1 2 3 4 5 6 7 8
| # OnlyOffice ENABLE_ONLYOFFICE = True VERIFY_ONLYOFFICE_CERTIFICATE = True ONLYOFFICE_APIJS_URL = 'https://你的seafile域名/onlyofficeds/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') ONLYOFFICE_JWT_SECRET = 'your-secret-string'
|
重启 Seafile 容器
执行以下命令
1 2
| docker-compose down docker-compose up -d
|
等待几分钟让 OnlyOffice 容器完成初始化。然后便可以使用 OnlyOffice。