haiwen / seafile

High performance file syncing and sharing, with also Markdown WYSIWYG editing, Wiki, file label and other knowledge management features.
http://seafile.com/
Other
12.19k stars 1.54k forks source link

Cannot integrate with Only Office #2791

Closed TheYoungBeast closed 1 month ago

TheYoungBeast commented 2 months ago

I followed this manual: https://manual.seafile.com/docker/pro-edition/deploy_onlyoffice_with_docker/

Here are the following config files: docker-compose.yaml:

services:
  db:
    image: mariadb:10.11
    container_name: seafile-mysql
    environment:
      - MYSQL_ROOT_PASSWORD=db_dev  # Required, set the root's password of MySQL service.
      - MYSQL_LOG_CONSOLE=true
      - MARIADB_AUTO_UPGRADE=1
    volumes:
      - /opt/seafile-mysql/db:/var/lib/mysql  # Required, specifies the path to MySQL data persistent store.
    networks:
      - seafile-net

  oods:
    image: onlyoffice/documentserver:latest
    container_name: seafile-oods
    networks:
      - seafile-net
    environment:
      - JWT_ENABLED=true
      - JWT_SECRET=your-secret-string

  memcached:
    image: memcached:1.6.18
    container_name: seafile-memcached
    entrypoint: memcached -m 256
    networks:
      - seafile-net

  seafile:
    image: seafileltd/seafile-mc:11.0-latest
    container_name: seafile
    ports:
      - "80:80"
      - "443:443"  # If https is enabled, cancel the comment.
    volumes:
      - /opt/seafile-data:/shared   # Required, specifies the path to Seafile data persistent store.
      - /opt/seafile/localhost.127.0.0.1.nip.io.key:/shared/ssl/localhost.127.0.0.1.nip.io.key
      - /opt/seafile/localhost.127.0.0.1.nip.io.crt:/shared/ssl/localhost.127.0.0.1.nip.io.crt
    environment:
      - DB_HOST=db
      - DB_ROOT_PASSWD=db_dev  # Required, the value should be root's password of MySQL service.
      - TIME_ZONE=Etc/UTC  # Optional, default is UTC. Should be uncomment and set to your local time zone.
      - SEAFILE_ADMIN_EMAIL=me@example.com # Specifies Seafile admin user, default is 'me@example.com'.
      - SEAFILE_ADMIN_PASSWORD=asecret     # Specifies Seafile admin password, default is 'asecret'.
      - SEAFILE_SERVER_LETSENCRYPT=false   # Whether to use https or not.
      - SEAFILE_SERVER_HOSTNAME=localhost.127.0.0.1.nip.io # Specifies your host name if https is enabled.
      - FORCE_HTTPS_IN_CONF=true # https://manual.seafile.com/docker/deploy_seafile_with_docker/#lets-encrypt-ssl-certificate
    depends_on:
      - db
      - memcached
    networks:
      - seafile-net

networks:
  seafile-net:

seafile.nginx.conf:

# -*- mode: nginx -*-
# Auto generated at 06/28/2024 18:36:33

# 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;
server_name localhost.127.0.0.1.nip.io;

    client_max_body_size 10m;

    location / {
        proxy_pass http://127.0.0.1:8000/;
        proxy_read_timeout 310s;
        proxy_set_header Host $http_host;
        proxy_set_header Forwarded "for=$remote_addr;proto=$scheme";
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Connection "";
        proxy_http_version 1.1;

        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;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        client_max_body_size 0;
        proxy_connect_timeout  36000s;
        proxy_read_timeout  36000s;
        proxy_request_buffering off;
        access_log      /var/log/nginx/seafhttp.access.log seafileformat;
        error_log       /var/log/nginx/seafhttp.error.log;
    }

    location /notification/ping {
        proxy_pass http://127.0.0.1:8083/ping;
        access_log      /var/log/nginx/notification.access.log seafileformat;
        error_log       /var/log/nginx/notification.error.log;
    }

    location /notification {
        proxy_pass http://127.0.0.1:8083/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        access_log      /var/log/nginx/notification.access.log seafileformat;
        error_log       /var/log/nginx/notification.error.log;
    }

    location /seafdav {
        proxy_pass         http://127.0.0.1:8080;
        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_set_header   X-Forwarded-Proto $scheme;
        proxy_read_timeout  1200s;
        client_max_body_size 0;

        access_log      /var/log/nginx/seafdav.access.log seafileformat;
        error_log       /var/log/nginx/seafdav.error.log;
    }

    location /media {
        root /opt/seafile/seafile-server-latest/seahub;
    }

    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;
    }
}

server {
    listen 443 ssl;

    server_name         localhost.127.0.0.1.nip.io;
    ssl_certificate     /shared/ssl/localhost.127.0.0.1.nip.io.crt;
    ssl_certificate_key /shared/ssl/localhost.127.0.0.1.nip.io.key;

    location / {
        proxy_pass http://127.0.0.1:8000/;
        proxy_read_timeout 310s;
        proxy_set_header Host $http_host;
        proxy_set_header Forwarded "for=$remote_addr;proto=$scheme";
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Connection "";
        proxy_http_version 1.1;

        client_max_body_size 0;
        access_log      /var/log/nginx/seahub.access.log seafileformat;
        error_log       /var/log/nginx/seahub.error.log;
    }

    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;
    }

    location /seafhttp {
        rewrite ^/seafhttp(.*)$ $1 break;
        proxy_pass http://127.0.0.1:8082;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        client_max_body_size 0;
        proxy_connect_timeout  36000s;
        proxy_read_timeout  36000s;
        proxy_request_buffering off;
        access_log      /var/log/nginx/seafhttp.access.log seafileformat;
        error_log       /var/log/nginx/seafhttp.error.log;
    }

    location /notification/ping {
        proxy_pass http://127.0.0.1:8083/ping;
        access_log      /var/log/nginx/notification.access.log seafileformat;
        error_log       /var/log/nginx/notification.error.log;
    }

    location /notification {
        proxy_pass http://127.0.0.1:8083/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        access_log      /var/log/nginx/notification.access.log seafileformat;
        error_log       /var/log/nginx/notification.error.log;
    }

    location /seafdav {
        proxy_pass         http://127.0.0.1:8080;
        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_set_header   X-Forwarded-Proto $scheme;
        proxy_read_timeout  1200s;
        client_max_body_size 0;

        access_log      /var/log/nginx/seafdav.access.log seafileformat;
        error_log       /var/log/nginx/seafdav.error.log;
    }

    location /media {
        root /opt/seafile/seafile-server-latest/seahub;
    }
}

seahub_settings.py:

# -*- coding: utf-8 -*-
SECRET_KEY = "b'%0yh_x#(l1v=^c!inc_ujo(g@yh(!0h66$cut316=ptauex-&h'"
SERVICE_URL = "http://localhost.127.0.0.1.nip.io"

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'seahub_db',
        'USER': 'seafile',
        'PASSWORD': 'e6c00257-4986-418a-a078-971e752f03f2',
        'HOST': 'db',
        'PORT': '3306',
        'OPTIONS': {'charset': 'utf8mb4'},
    }
}

CACHES = {
    'default': {
        'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
        'LOCATION': 'memcached:11211',
    },
    'locmem': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
    },
}
COMPRESS_CACHE_BACKEND = 'locmem'
TIME_ZONE = 'Etc/UTC'
FILE_SERVER_ROOT = "https://localhost.127.0.0.1.nip.io/seafhttp"

# OnlyOffice
ENABLE_ONLYOFFICE = True
VERIFY_ONLYOFFICE_CERTIFICATE = False
ONLYOFFICE_APIJS_URL = 'https://localhost.127.0.0.1.nip.io/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-oods logs:

==> /var/log/onlyoffice/documentserver/docservice/out.log <==
[2024-06-28T19:27:39.463] [ERROR] [localhost] [c99351689f51d884ca6d] [me@example.com] nodeJS - postData error: url = http://localhost.127.0.0.1.nip.io/onlyoffice/editor-callback/;data = {"key":"c99351689f51d884ca6d","status":1,"users":["me@example.com"],"actions":[{"type":1,"userid":"me@example.com"}],"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJjOTkzNTE2ODlmNTFkODg0Y2E2ZCIsInN0YXR1cyI6MSwidXNlcnMiOlsibWVAZXhhbXBsZS5jb20iXSwiYWN0aW9ucyI6W3sidHlwZSI6MSwidXNlcmlkIjoibWVAZXhhbXBsZS5jb20ifV0sImlhdCI6MTcxOTYwMjg1OSwiZXhwIjoxNzE5NjAzMTU5fQ.PPzsKZyiqYrQMIZJXuYm9GofW0jsThW0TfgqPh7F1KM"} Error: Error response: statusCode:404; headers:{"server":"nginx","date":"Fri, 28 Jun 2024 19:27:39 GMT","content-type":"text/html; charset=utf-8","transfer-encoding":"chunked","connection":"keep-alive","vary":"Accept-Encoding","content-security-policy":"default-src 'none'","x-content-type-options":"nosniff","content-encoding":"gzip"}; body:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /onlyoffice/editor-callback/</pre>
</body>
</html>

    at Request._callback (/snapshot/server/Common/sources/utils.js)
    at Request.callback (/snapshot/server/Common/node_modules/request/request.js:185:22)
    at Request.emit (node:events:527:28)
    at Request.<anonymous> (/snapshot/server/Common/node_modules/request/request.js:1161:10)
    at Request.emit (node:events:527:28)
    at Gunzip.<anonymous> (/snapshot/server/Common/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (node:events:641:28)
    at Gunzip.emit (node:events:527:28)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

==> /var/log/onlyoffice/documentserver/converter/out.log <==
[2024-06-28T19:27:39.470] [ERROR] [localhost] [c99351689f51d884ca6d] [me@example.com] nodeJS - error downloadFile:url=https://localhost.127.0.0.1.nip.io/seafhttp/files/d4656faf-66b4-4087-995c-a67cc7fd087f/kaka.docx;attempt=1;code:ECONNREFUSED;connect:null Error: connect ECONNREFUSED 127.0.0.1:443
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)
[2024-06-28T19:27:40.472] [ERROR] [localhost] [c99351689f51d884ca6d] [me@example.com] nodeJS - error downloadFile:url=https://localhost.127.0.0.1.nip.io/seafhttp/files/d4656faf-66b4-4087-995c-a67cc7fd087f/kaka.docx;attempt=2;code:ECONNREFUSED;connect:null Error: connect ECONNREFUSED 127.0.0.1:443
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)
[2024-06-28T19:27:41.475] [ERROR] [localhost] [c99351689f51d884ca6d] [me@example.com] nodeJS - error downloadFile:url=https://localhost.127.0.0.1.nip.io/seafhttp/files/d4656faf-66b4-4087-995c-a67cc7fd087f/kaka.docx;attempt=3;code:ECONNREFUSED;connect:null Error: connect ECONNREFUSED 127.0.0.1:443
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)

Version: Seafile CE 11.0

I tried multiple times with multiple configurations. It is unclear to me how to properly integrate only office with SeaFiles. The manual seems not to work out of the box. I've seen multiple similar issues and none of them had answers.

I would greatly appreciate your help.

dunfusheng commented 1 month ago

I noticed that you are using HTTPS,so the settings of this SERVICE_URL should be "https://localhost.127.0.0.1.nip.io".