Integration of Seafile and Onlyoffice Document Server

Previously, the site considered articles on installing the Seafile file storage server and installing the Onlyoffice Document Server

Consider the option of integrating these two services

We stop services seafile, seahub

$ sudo systemctl stop seafile seahub

Editing the nginx config

$ sudo nano /etc/nginx/sites-available/seafile.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;
    }
[...]
    location /onlyofficeds/ {

        # THIS ONE IS IMPORTANT ! - Trailing slash !
        proxy_pass https://onlyoffice.example.ru/;

        client_max_body_size 100M; # Limit Document size to 100MB
        proxy_read_timeout 3600s;
        proxy_connect_timeout 3600s;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $proxy_connection;
        proxy_http_version 1.1;

        # THIS ONE IS IMPORTANT ! - Subfolder and NO trailing slash !
        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;
    }

Checking

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Restart nginx

$ sudo systemctl restart nginx

Editing the seahub_settings.py config

$ sudo nano /opt/seafile/conf/seahub_settings.py
[...]
# Enable Only Office
ENABLE_ONLYOFFICE = True
VERIFY_ONLYOFFICE_CERTIFICATE = True
ONLYOFFICE_APIJS_URL = 'https://seafile.example.ru/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')

We start previously stopped services

$ sudo systemctl start seafile seahub

Important. When integrating Seafile and Onlyoffice in a test environment (in VirtualBox virtual machines), editing in onlyoffice did not work: the document editor’s web interface loaded, but then an error appeared. When installing server integration in a production environment, and using real domain names, everything worked normally.

Sidebar