Use Docker and self-signed certificates to configure Onlyoffice for Nextcloud (1)

Nextcloud can achieve seamless integration with Onlyoffice through a plug-in, which is an open source online viewing and editing office document tool. Onlyoffice's official website is: https://www.onlyoffice.com . To achieve seamless integration of the two, you first need to install and configure Onlyoffice Document Server, and then install the corresponding plug-in for Nextcloud and complete the configuration.

1. Use Docker to quickly install and deploy Onlyofiice Document Server

1. Install and configure the Docker environment

For the configuration of the Docker environment, you can refer to the relevant page of the rookie tutorial related tutorials ( https://www.runoob.com/docker/ubuntu-docker-install.html ) which is not repeated here.

2. Download the Onlyoffice / DocumentServer image

$ docker pull onlyoffice/documentserver

After the command is executed, you can see the specific download progress. Due to the large image file (about 500MB, about 2GB after decompression), the download time may be longer. Domestic users are recommended to choose morning download, which is faster. If the download is successful, you will see information about the downloaded image:

$ docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
onlyoffice/documentserver   latest              d06214a03e27        2 weeks ago         2.14GB

If you are prompted that there is no permission, you can add sudo before the command, or give the current user permission to run the docker command. For the operation of giving the current user authority, please refer to the rookie tutorial page in the first step.

3. Run the container

Run the following code to create the container and start it:

$ docker run -itd \
    --name onlyoffice \
    -p 9000:443 \
    -p 9080:80 \
    -v $(pwd)/onlyoffice/DocumentServer/logs:/var/log/onlyoffice  \
    -v $(pwd)/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data  \
    onlyoffice/documentserver

If the container starts successfully, you can check the container status with the following command:

$ docker ps -a
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                                         NAMES
b10cb4ca780b        onlyoffice/documentserver   "/bin/sh -c /app/ds/…"   3 hours ago         Up 59 minutes       0.0.0.0:9080->80/tcp, 0.0.0.0:9000->443/tcp   onlyoffice

4. Configure https certificate

Use the root certificate created by yourself to sign the certificate for the Onlyoffice document server. For the specific process, please refer to the sixth part of the article " Deploying NextCloud with Docker Technology ". It should be noted that the CommonName of the certificate must be set to the domain name of the website (without https and port number), otherwise an error will be reported when configuring nextcloud to access the onlyoffice part.

The process of opening https for Onlyoffice document server is very simple, just create the certs directory under $ (pwd) / onlyoffice / DocumentServer / data, and put the private key and certificate file in it, the author's $ (pwd) / onlyoffice / The contents of the DocumentServer / data / certs directory are as follows:

$ ls -l  $(pwd)/onlyoffice/DocumentServer/data/certs
total 8
-rwxr-xr-x 1 lxd syslog 1558 Apr 21 06:55 onlyoffice.crt
-rwxr-xr-x 1 lxd syslog 1679 Apr 21 06:55 onlyoffice.key

5. Turn off client certificate authentication

By default, onlyoffice will authenticate the client's certificate. Since we use a self-signed certificate, the authentication will definitely fail. Therefore, we choose to close the corresponding authentication. The specific method of closing is to modify the container / etc / onlyoffice / documentserver /default.json file. To do this, we need to first copy the file out of the container, make the appropriate changes, and then copy it back. The command to copy the configuration file from the container to the current directory is:

$ docker cp nextcloud:/etc/onlyoffice/documentserver/default.json .

After copying out the file, use any text editor to find the "rejectUnauthorized" setting and change its value to "false". The contextual text fragment of the setting item after the author changes is as follows:

                         "requestDefaults": {
                                "headers": {
                                        "User-Agent": "Node.js/6.13"
                                },
                                "rejectUnauthorized": false
                        },

The command to copy the file back to the container is as follows:

$ docker cp default.json nextcloud:/etc/onlyoffice/documentserver/default.json

6. Restart the container to make the configuration take effect

$ docker restart onlyoffice

At this point, the Document server configuration of Onlyoffice is complete, you can visit https: // <your-domain>: 9000 / through the browser to see the "Document Server is running" page

Published 43 original articles · Like9 · Visit 230,000+

Guess you like

Origin blog.csdn.net/boliang319/article/details/105650310