OnlyOffice integration as SNAP

Hello community,

I am looking for some support to analyze my issue with the OnlyOffice integration.

I installed seafile manually with nginx. Everything is working fine and for testing purpose I am working with HTTP only.
Now I installed OnlyOffice on the same host but as SNAP package. I am not a big fan of docker so I’d like to give it a try.

After the SNAP installation I had the first issues, seafile was no longer available.
The reason was that the SNAP package uses the same tcp ports as seafile by default does.
So I fixed this and now I can reach seafile and the welcome page of OnlyOffice.

But if I try to open a DOC document I only get a blank page.
I think something is messed up in nginx but I copy & pasted from the manual and changed the needed ports.

Maybe someone of you have tried the same or has a good idea what I am doing wrong.

Greetings,
Tom

Technical information:
IP: 192.168.178.80
Seafile-Nginx listener: 0.0.0.0:80
Seafile-SQL listener: 127.0.0.1:3306
Seafile-Gunicorn listener: 0.0.0.0:8024
OnlyOffice-Nginx(SNAP) listener: 0.0.0.0:8888

ccnet.conf
[General]
USER_NAME = Seafile-Cloud
ID = 1e8011807e528cba2191ea587f4bde0ab50a17c6
NAME = Seafile-Cloud
SERVICE_URL = HTTP 192.168.178.80

[Client]
PORT = 13419

[Database]
ENGINE = mysql
HOST = 127.0.0.1
PORT = 3306
USER = seafile
PASSWD = password
DB = ccnet-db
CONNECTION_CHARSET = utf8
gunicorn.conf
import os

daemon = True
workers = 5

# default localhost:8000
#bind = "127.0.0.1:8000"
bind = "0.0.0.0:8024"

# Pid
pids_dir = '/opt/haiwen/pids'
pidfile = os.path.join(pids_dir, 'seahub.pid')

# for file upload, we need a longer timeout value (default is only 30s, too short)
timeout = 1200

limit_request_line = 8190
seahub_settings.py
# -*- coding: utf-8 -*-
SECRET_KEY = "du)r0g#0yu_x-f2yngv2&)v$j-pptuhcys^0bwnc9oa(-$8x7k"
FILE_SERVER_ROOT = 'HTTP 192.168.178.80/seafhttp'
# Enable Only Office
ENABLE_ONLYOFFICE = True
VERIFY_ONLYOFFICE_CERTIFICATE = False
ONLYOFFICE_APIJS_URL = 'HTTP 127.0.0.1:8888/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')

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'seahub-db',
        'USER': 'seafile',
        'PASSWORD': 'password',
        'HOST': '127.0.0.1',
        'PORT': '3306'
    }
}
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;
    }
log_format seafileformat '$http_x_forwarded_for $remote_addr [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $upstream_response_time';
server {
    listen 80;
    server_name 192.168.178.80;
    proxy_set_header X-Forwarded-For $remote_addr;
    location / {
         proxy_pass         HTTP 127.0.0.1:8024;
         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   X-Forwarded-Host $server_name;
         proxy_read_timeout  1200s;
         # used for view/edit office file via Office Online Server
         client_max_body_size 0;
         access_log      /var/log/nginx/seahub.access.log seafileformat;
         error_log       /var/log/nginx/seahub.error.log;
    }
    location /seafhttp {
        rewrite ^/seafhttp(.*)$ $1 break;
        proxy_pass HTTP 127.0.0.1:8082;
        client_max_body_size 0;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_connect_timeout  36000s;
        proxy_read_timeout  36000s;
        proxy_send_timeout  36000s;
        send_timeout  36000s;
        access_log      /var/log/nginx/seafhttp.access.log seafileformat;
        error_log       /var/log/nginx/seafhttp.error.log;
    }
    location /media {
        root /opt/haiwen/seafile-server-latest/seahub;
    }
    location /onlyofficeds/ {
        # THIS ONE IS IMPORTANT ! - Trailing slash !
        proxy_pass HTTP 127.0.0.1:8888/;
        proxy_http_version 1.1;
        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;
        # 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;
    }
}

Welcome to the Seafile Community Forum! Let me try to help you.

Please try to call http://192.168.178.80/onlyofficeds/welcome.

If you receive the answer “Document Server is running”, you’re 99% there.

add “/onlyofficeds” behind “127.0.0.1:8888” (should then be ‘HTTP 127.0.0.1:8888/onlyofficeds/web-aps/apps/api/documents/api.js’

Good luck

Hello rdb,

thank you for your fast reply.
If I try to call the URL I receive a page in Seafiles web design telling me that the site was not found.
Moreover the URL is changed to:
HTTP 192.168.178.80/welcome/

When I call 192.168.178.80:8888 I get the correct welcome page for OnlyOffice.

Did you try the rest?

Hold on: 192.168.178.80/onlyofficeds/welcome and 192.168.178.80:8888 did not yield the same result? Did you restart nginx after the modification? But it should because the folder /onlyoffice is proxy passed to port 8888 according to your Nginx conf.

Please execute:
nginx -t
nginx -s reload

Apologies! It was late yesterday evening. Since /onlyofficeds is proxy-passed to port 8888 by Nginx, my recommendation from yesterday night was not correct. The port has to disappear from the URL.

I restarted nginx and the config file is tested without any errors.

But I find a mistake by myself:
192.168.178.80/onlyofficeds/welcome -> gives me the “not found” page
192.168.178.80/onlyofficeds/welcome/ -> shows the correct welcome page of OnlyOffice
So I missed the trailing / while opening the URL.

Now I tried your other change too and switched from:
ONLYOFFICE_APIJS_URL = ‘HTTP 127.0.0.1:8888/web-apps/apps/api/documents/api.js’
to:
ONLYOFFICE_APIJS_URL = ‘HTTP 127.0.0.1/onlyofficeds/web-apps/apps/api/documents/api.js’

I think this is what you mean with our last comment, don’t you?
Just for fun I also tried the following line:
ONLYOFFICE_APIJS_URL = ‘HTTP 127.0.0.1:8888/onlyofficeds/web-apps/apps/api/documents/api.js’

After doing the change I always stopped and started seafile and seahub.

Sadly I still get the blank page if I try to open the document.
Maybe it is useful to mention how the accessed URL for the document looks like:
192.168.178.80/lib/9215e95c-27cf-4b0e-b88c-008df2f9f3c1/file/seafile-tutorial.doc

Thank you for your help :slight_smile:

I tried to open the DOC again while having the chrome developer console open:
The console prints that the following file cannot be loaded:
“HTTP 127.0.0.1/onlyofficeds/web-apps/apps/api/documents/api.js”.

That’s true instead of 127.0.0.1 192.168.178.80 is required, than I can open the JS file.

This is fine.

Exactly.

Not sure what you mean by this?

I made a screenshot so that you can see what I have done:

In the developer console at the bottom you can see that the page tries to access the URL:
HTTP 127.0.0.1/onlyofficeds/web-apps/apps/api/documents/api.js

But the browser cannot access 127.0.0.1. If I change 127.0.0.1 with my seafile server IP address 192.168.178.80 than the JS file is loaded.

Could this be the issue?

Yes I got it running.

I changed:
ONLYOFFICE_APIJS_URL = ‘HTTP 127.0.0.1/onlyofficeds/web-apps/apps/api/documents/api.js’
to:
ONLYOFFICE_APIJS_URL = ‘HTTP 192.168.178.80/onlyofficeds/web-apps/apps/api/documents/api.js’

Because of this my client was able to load the api.js file from the screenshot above and I can see and edit the document.

This means that the ONLYOFFICE_APIJS_URL variable always needs the public IP/Domain of my server. Is this right and the intendet behavior?

Glad to hear that it works now.

Re. your question: The manual states under the headline “Config Seafile and OnlyOffice in the same machine”:

After the installation process is finished, visit this page to make sure you have deployed OnlyOffice successfully: `http{s}://{your Seafile Server's domain or IP}/{your subdolder}/welcome` , you will get **Document Server is running** info at this page.

Actually, the doesn’t say “http{s}://localhost” but if refers explicitly to domain or IP. For some reason localhost does not seem to work. So I guess it is intended.

Alright.

Thank you again for your help. :slight_smile: