I recently needed to provide a private document repository to a small
group of people who didn't want to use Google Docs. I would have liked
to propose DokuWiki running in my
Sandstorm
server, but there were too many existing .docx documents to contend
with, and the users preferred to deal with a folder-based structure than
a wiki.
I decided, after several hours of research, to use
Nextcloud
to store and manage access to files, and use
OnlyOffice Docs
alongside to view and edit the documents, spreadsheets, and
presentations. This has worked out quite well on the whole, though it
took some effort to set it up, and there were a few warts along the way.
Some factors that went into this decision: both projects are open source
and are actively maintained. Nextcloud supports all of the necessary
file management features (especially sharing files with different
permissions for individuals and groups) with a simple and pleasant
interface; and the community edition of OnlyOffice is enough to edit
most .docx files. There is also generally positive feedback from people
who are using these two programs in combination.
Overview
I was not familiar with either Nextcloud or OnlyOffice, and it took
quite a while to figure out the various moving parts and how best to
fit them all together. This is my summary of the process, based on the
experiments I did and the bits and pieces of documentation I consulted
along the way. These are not step-by-step installation instructions, but
they might save you some time and point you in the right direction.
Nextcloud stores files and manages access to them, so it's like Google
Drive for our purposes. (It has many other features, and you can install
all manner of apps developed for Nextcloud, but those capabilities were
not relevant to me here.) It is also the interface that you and your
users will interact with to create users, manage permissions, and upload
files. (You can also view PDFs and collaboratively edit text or Markdown
files.)
OnlyOffice Document Server
edits files stored in Nextcloud and plays the role of Google Docs.
There's also something called
OnlyOffice Community Server;
in theory, it may be able to replace Nextcloud, but I wasn't sure if all
the relevant features were
available in the open source edition.
In any case, Nextcloud looked more solid to me, so I didn't try.
System layout
Nextcloud is written in PHP, while OnlyOffice is a Node.JS application.
Both need a database (Postgres works) and bits of other infrastructure
besides. The most convenient way to get started with them is to use the
official Docker images
(Nextcloud,
OnlyOffice).
Both projects also publish installation documentation
(Nextcloud,
OnlyOffice)
if you prefer to install them directly on your server.
I made my life slightly harder by wanting to run both applications
inside Docker containers, but also to use the nginx and Postgres servers
that I was already running. I also wanted to use php-fpm to run
Nextcloud, for better performance. It took a fair bit of
experimentation, but I settled on a configuration that I liked.
Users access this system as “nextcloud.example.org”, which goes to the
system-wide nginx, which forwards to the Nextcloud container. The two
dashed arrows show how the applications communicate with each other.
OnlyOffice also publishes some more
details about the integration.
Nextcloud
I used the
nextcloud:fpm
Docker image, which runs the application under
php-fpm,
a FastCGI process manager that nginx can forward requests to.
This image has documentation, including
examples of how to use it,
and an
nginx.conf
to show how to configure the frontend nginx (see below).
OnlyOffice provides another example of
how to use both applications.
OnlyOffice Document Server
I used the
onlyoffice/documentserver:latest
Docker image.
This image is large, complex, and not particularly well documented. It
runs the document server and associated services behind nginx, but also
has Postgres, redis, and RabbitMQ installed, and it uses them unless you
configure it to use external services, as I did.
I would like to get rid of the second nginx and build a simpler image
that runs only the document server. For now, however, I run the image
as-is.
System services
I was already running nginx, so I added a new virtual host for
Nextcloud, following the
example nginx.conf.
Here's the operative part that forwards PHP execution requests to
php-fpm inside the Nextcloud container:
location ~ \.php(?:$|/) {
fastcgi_pass nextcloud;
fastcgi_request_buffering off;
fastcgi_read_timeout 300;
fastcgi_buffering off;
…
}
I used my existing
acme.sh setup
to generate a LetsEncrypt certificate for the Nextcloud application's
domain. If you don't already have a way to handle TLS certificates for
your domain, the
Nextcloud documentation
has some suggestions and Docker-based examples.
I was already running Postgres, so I just created separate users
and databases for both Nextcloud and OnlyOffice. (Both applications will
create their own tables during installation.)
I was already running Postfix, so I just configured Nextcloud to
use that SMTP server to send outgoing mail (e.g., to notify you that
someone has shared a document with you).
Redis (for Nextcloud) and RabbitMQ (for OnlyOffice) are
optional. You can run them in Docker containers if you like, or run them
on the host, as I did. As with the other services, you just need to
point the application in the container to the correct port on the host.
Configuration
I've written this up as a
docker-compose
configuration file, but I'm not publishing it here until I can fix the
problem mentioned below.
Upgrades
I installed Nextcloud 19 and OnlyOffice 6.0 to begin with, but Nextcloud
20.0.0 was released soon afterwards, followed by Nextcloud
20.0.1 and OnlyOffice 6.0.1. Future upgrades may require more effort,
but the first three were easy.
To apply each upgrade, all I needed to do
was to pull the new image
(nextcloud:fpm and
onlyoffice/documentserver:latest),
stop the old container, and start it again with the updated image. Done.
Open problems
I managed to solve various problems while setting the system up, but
there's one big problem left — opening a document for the
first time is unbelievably, painfully slow.
Clicking on a document in Nextcloud opens an OnlyOffice tab, which then
spends a long time “Loading document”. Even the 25KB example .docx file
that ships with Nextcloud can take several minutes to load. Usually, but
not always, the file loads normally on subsequent attempts after the
first successful one.
I haven't been able to figure out this problem, despite increasing the
log level for both Nextcloud and OnlyOffice and poking around a bit. I
tried to use the public OnlyOffice demo server, and that was also slow.
There are some
reports on the Nextcloud forum
of this behaviour, but no conclusive analyses or solutions.
I'll update this page once I find a solution to this problem.
Questions? Suggestions? Feedback?
I'm not a Nextcloud or OnlyOffice or Docker expert, so I may not know
the answer to your question, but you're welcome to ask. I also welcome
suggestions to improve my setup or this article.
Write to me at
ams@toroid.org