用 Docker 部署 OnlyOffice

将 OnlyOffice 加入到 docker-compose.yml

将以下内容添加到 services 章节中

services:
  ...
  oods:
    image: onlyoffice/documentserver:latest
    container_name: seafile-oods
    networks:
      - seafile-net
    environment:
      - JWT_ENABLED=true
      - JWT_SECRET=seafile123     ##可以自定义

注意:JWT_SECRET 选项配置是安全认证秘钥 ,要和seahub_settings.py中的ONLYOFFICE_JWT_SECRET选项保持一致,内容可自定义填写

将 OnlyOffice 加入到 nginx conf 中

seafile.nginx.conf

# Required for only office document server
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

# OnlyOffice
ENABLE_ONLYOFFICE = True
VERIFY_ONLYOFFICE_CERTIFICATE = True
ONLYOFFICE_APIJS_URL = 'http://<your-seafile-doamin>/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 = 'seafile123'     ## 和docker-compose.yml 中保持一致

注意: your-seafile-doamin 是指您seafile的服务器的 ip / 域名+端口

重启 Seafile 容器

执行以下命令

docker compose down
docker compose up -d 

等待几分钟让 OnlyOffice 容器完成初始化。然后便可以使用 OnlyOffice。

Last modified by 郑杰, 2023-10-24

将 OnlyOffice 加入到 docker-compose.yml
将 OnlyOffice 加入到 nginx conf 中
修改 seahub_settings.py
重启 Seafile 容器