神族九帝

神族九帝

Getting Started with Onlyoffice

Installing OnlyOffice Community Edition with Docker#

sudo docker run -i -t -d -p 8701:80 onlyoffice/documentserver

The official recommendation is to store data outside of the Docker container, as this allows for easy updates of ONLYOFFICE Docs without losing data. Therefore, use the following command:

sudo docker run -i -t -d -p 8701:80 --restart=always \
    -v /app/onlyoffice/DocumentServer/logs:/var/log/onlyoffice  \
    -v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data  \
    -v /app/onlyoffice/DocumentServer/lib:/var/lib/onlyoffice \
    -v /app/onlyoffice/DocumentServer/db:/var/lib/postgresql -e JWT_SECRET=my_jwt_secret onlyoffice/documentserver
  • -p 8701:80 represents port mapping, where the former is the host port and the latter is the container's mapped port.
  • --restart=always automatically restarts the container.
  • onlyoffice/documentserver is the image name.
  • -e JWT_SECRET=my_jwt_secret is the secret key.

Explanation of data volumes:

  • /var/log/onlyoffice for ONLYOFFICE document logs.
  • /var/www/onlyoffice/Data for certificates.
  • /var/lib/onlyoffice for file caching.
  • /var/lib/postgresql for the database.

Starting from version 7.2, JWT authentication is enabled by default. If a custom key is not added during installation, a random key will be generated automatically.

sudo docker exec 6b1c15f3204c /var/www/onlyoffice/documentserver/npm/json -f /etc/onlyoffice/documentserver/local.json 'services.CoAuthoring.secret.session.string'

image.png

Click "Go To Example" to access the document editor example.

image.png

Reference link:

Node Integration#

Download the Node instance:
Next, we need to modify the document server address in config/default.json.

"storageFolder": "./files"
"storagePath": "/files"
"siteUrl": "https://documentserver/"

documentserver is the IP address of the installed server. We can modify storageFolder and storagePath according to the actual situation.
We also need to modify the secret key in the token section.

    "token": {
      "enable": true,
      "secret": "my_jwt_secret",
      ...
    },

Modified content:
image.png
image.png
Start the project and access http://localhost:3000 in the browser.
The interface after entering is the same as the Docker Example.
image.png

Frontend Integration#

Issues#

The document security token is not correctly formed. Please contact your Document Server administrator.#

image.png
image.png

There are two situations that can cause this issue, both of which involve not having a secret key. One is when the secret key is not disabled during Docker installation, and the other is when the key is enabled but Node does not have the conversion enabled or the key is filled in incorrectly.

Download failed#

image.png
image.png

The reason is that our document server is installed in Docker. For the Docker service, localhost:3000 does not have this file. Typically, the IP address of the URI should be set to a local IP address that is accessible externally, not localhost, 127.0.0.1, or the internal IP of the machine. Therefore, we need to access it through the local IP address. In a real production environment, a domain name would be assigned. Using the IP or domain name will allow successful access.

Reference link:

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.