Seafile server tries to connect the wrong address when working with an OnlyOffice document

server

#1

Hi there,

when I’m trying to edit a document within my Seafile Docker installation with OnlyOffice (also Docker), I get the following error in the logs:

==> /var/log/onlyoffice/documentserver/docservice/out.log <==
[2019-05-08T18:57:59.892] [ERROR] nodeJS - postData error: docId = e2e36b12fb4e26002edd;url = hxxp://cloud.xyz:8000/onlyoffice/editor-callback/;data = {"key":"e2e36b12fb4e26002edd","status":1,"users":["uid-1557341879290"],"actions":[{"type":1,"userid":"uid-1557341879290"}]}
Error: connect ECONNREFUSED 188.xx.xx.xx:8000
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)

I also get a pop up message in OnlyOffice which states that the document cannot be saved. If i click “Ok” I can work in the loaded document afterwards, however if I change something, this change isn’t stored at SeaFile.

What confuses me is, that the SeaFile Docker Container tries to contact itself on port 8000 instead of the OnlyOffice container. The OnlyOffice Container is setup with a subdomain like described in the official SeaFile OnlyOffice integration tutorial.

At my seahub_settings.py file I appended the following lines and restarted the SeaFile and OnlyOffice Containers afterwards:

ENABLE_ONLYOFFICE = True
VERIFY_ONLYOFFICE_CERTIFICATE = False
ONLYOFFICE_APIJS_URL = ‘hxxps://office.xyz:4443/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’)

The OnlyOffice container and the SeaFile container are sharing one public IPv4 address, resulting in cloud.xyz and office.xyz both pointing on this public address … if this does matters.

If you need more information, please let me know.

Thanks in advance

PS: A telnet on localhost or cloud.xyz at port 8000 is also resulting in connection refused. What am I missing here?


#2

Is this previous post relevant to your current interest?


#3

Thanks for your answer. Your link is not addressing my problem but it gave me some hints for further searching.

I solved the problem. My OnlyOffice and my SeaFile containers are on the same host system. I’ve created a Docker network bridge dedicated for this cloud and added both containers to this network with a fixed IP address. At the creation command of the OnlyOffice container I also used the following parameter: --add-host mycloud.mydomain.com:172.20.0.2. As a result of this parameter, an entry at /etc/hosts is created within the OnlyOffice Docker container pointing mycloud.mydomain to 172.20.0.2 instead of the public IP address. This means that the connection to the SeaHub on port 8000 isn’t get blocked anymore because the communication never leaves the Docker network bridge.


#4

This sounds like a really great piece of work on your part. Perhaps you would be willing to write a short procedure of how you went about implementing the setup and post it here so that others can try it?

It sounds like it would be a significant contribution to the information we have on how to deploy Seafile Docker with OnlyOffice. This could be a huge benefit to others.

-Thank you


#5

Sure. Basically I justed used the following (example) command to create the SeaFile Docker container:

sudo docker run -d --name seafile --net cloud --ip 192.168.20.2 -e SEAFILE_SERVER_LETSENCRYPT=true -e SEAFILE_SERVER_HOSTNAME=cloud.myserver.com -e SEAFILE_ADMIN_EMAIL=me@mymail.com -e SEAFILE_ADMIN_PASSWORD=‘MyPW’ -v /srv/seafile:/shared -p 80:80 -p 443:443 seafileltd/seafile:latest

As you can see I’m using a dedicated Docker network which is called “cloud”. I created this network before the docker create command of course. The network allows me to set fixed IP addresses for Docker containers. The IP address 192.168.20.2 (which is the fixed IP address for the SeaFile Docker container in the example above) can now be used within the docker create command for the OnlyOffice container:

sudo docker run -i -t -d -p 8443:443 --name onlyoffice --net cloud --ip 192.168.20.3 --add-host cloud.myserver.com:192.168.20.2 -v /srv/onlyoffice/logs:/var/log/onlyoffice -v /srv/onlyoffice/data:/var/www/onlyoffice/Data onlyoffice/documentserver:latest

As already stated, the --add-host parameter will set a static entry in the /etc/hosts file within the OnlyOffice container. This forces the OnlyOffice container to communicate through port 9000 over the internal Docker network (cloud) instead of going through the world wide web. An alternative would be to expose the SeaHub port 9000 at the creation of the SeaFile Docker container, but I guess that this could be considered as a security risk (at the official SeaFile Docker instructions you can’t find a word about doing so either).

I’ve created a extended tutorial recently on my blog about how to implement this setup if you need more information. Unfournatly I’m not allowed to post links here so the easiest way would be to go to my blog (unixbloggerDOTcom) and search for “SeaFile OnlyOffce”.

Hope that’s helpful for others :slight_smile:


#6

For those who want the step-by-step details of the procedure it can be found here.

The writing is clear, concise and easy to follow. Thank you, linuxrecon.