OnlyOffice: Difference between revisions

From Newroco Tech Docs
Jump to navigationJump to search
No edit summary
 
Line 224: Line 224:
<private.IP.address>    <hostname> <hostname>.defaultdomain
<private.IP.address>    <hostname> <hostname>.defaultdomain
</syntaxhighlight>
</syntaxhighlight>
==File recovery==
In the event that you need to recover a file that was edited by OnlyOffice but for some reason can no longer be written back to the location/downloaded etc., it is possible to perform a manual recovery of a file.
The first challenge is identifying the file; the chances are that if it is a file experiencing issues you'll find it in the logs, most likely in a current or older ''/var/log/onlyoffice/documentserver/docservice/out.log'';  if you search by username this may reveal the document ID, a 10 digit number; this number corresponds to the file cache location subfolder in ''/var/lib/onlyoffice/documentserver/App_Data/cache/files/''. If this folder exists then within it is a file "Editor.bin", which is a binary state "dump" used by OnlyOffice while the file is open. Take a copy of the file to temp in case something cleans it up before you can complete the next step.
Now in Nextcloud create a new blank document (not sure if it has to be the same type, it's possible the Editor.bin file contains that info) and then immediately check for a newly created folder in ''/var/lib/onlyoffice/documentserver/App_Data/cache/files/''. Having identified the folder, carry out these commands on the OnlyOffice server:
  cp /var/lib/onlyoffice/documentserver/App_Data/cache/files/<mynewdocid>/Editor.bin /var/lib/onlyoffice/documentserver/App_Data/cache/files/<mynewdocid>/Editor.bin.old
  cp /mytemplocation/editor.bin /var/lib/onlyoffice/documentserver/App_Data/cache/files/<mynewdocid>/Editor.bin
Now switch back to your browser and reload the OnlyOffice tab showing your new blank document. The content of the recovered document should load.

Latest revision as of 16:54, 16 November 2021

Preparing the Install

Document Server uses NGINX and PostgreSQL as database. Dependencies found in the system repository will be installed automatically at Document Server installation using the apt-get install command.

Installing and configuring PostgreSQL:

Install the PostgreSQL version included in your version of Ubuntu:

sudo apt-get install postgresql

After PostgreSQL is installed, create the PostgreSQL database and user:

sudo -i -u postgres psql -c "CREATE DATABASE onlyoffice;"
sudo -i -u postgres psql -c "CREATE USER onlyoffice WITH password 'onlyoffice';"
sudo -i -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;"

Installing redis:

sudo apt-get install redis-server

Installing rabbitmq:

sudo apt-get install rabbitmq-server

Ubuntu 18.04 will require to install nginx-extras. This is done using the command:

sudo apt-get install nginx-extras

Installing Document Server

Add GPG key:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5

Add Document Server repository:

sudo echo "deb https://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list

Update the package manager cache:

sudo apt-get update

Install Document Server

sudo apt-get install onlyoffice-documentserver

Rebuilding spellchecker (Ubuntu 18.04)

For the spellchecker to work correctly under Ubuntu 18.04 you will need to rebuild it. This is done the following way:

Update npm:

sudo npm install -g npm

Stop Document Server services:

sudo supervisorctl stop all

Install the components necessary for the build:

sudo apt-get install build-essential git

Switch to the spellchecker folder:

cd /var/www/onlyoffice/documentserver/server/SpellChecker/

Delete the older build:

sudo mv node_modules/ node_modules_old/

Install the dependencies:

sudo npm install

And finally start back Document Server services:

sudo supervisorctl start all

Restrict OnllyOffice to one NextCloud server

1. Edit /etc/onlyoffice/documentserver/local.json file as follow:

{
  "services": {
    "CoAuthoring": {
      "sql": {
        "type": "postgres",
        "dbHost": "localhost",
        "dbPort": "5432",
        "dbName": "onlyoffice",
        "dbUser": "onlyoffice",
        "dbPass": "onlyoffice"
      },
      "redis": {
        "host": "localhost"
      },
      "token": {
        "enable": {
          "request": {
            "inbox": true,
            "outbox": true
          },
          "browser": true
        },
        "inbox": {
          "header": "<header>"
        },
        "outbox": {
          "header": "<header>"
        }
      },
      "secret": {
        "inbox": {
          "string": "<secret>"
        },
        "outbox": {
          "string": "<secret>"
        },
        "session": {
          "string": "<secret>"
        }
      }
    }
  },
  "rabbitmq": {
    "url": "amqp://guest:guest@localhost"
  }
}

NOTE: The "secret' can be generated using this command:

openssl rand -base64 16

2. Restart the service:

sudo supervisorctl restart all

3. Add the following lines to /var/www/nextcloud/config/config.php on NexctCloud server

  'onlyoffice' =>
  array (
    "jwt_header" => "<header>"
  ),

4. Restart the service:

sudo apache2ctl graceful

5. Go to Nextcloud web interface, navigate to Apps menu, then search for OnlyOffice and install it.

6. On Nextcloud web interface go Settings-Onlyoffice and complete the configuration and add the jwt_secret as follow:

Onlyoffice-config.png

Set-up vhost proxy for OnlyOffice

<VirtualHost *:80>
    ServerName ooserver.newro.co

    ProxyPass / http://172.17.13.17/
    ProxyPassReverse / http://172.17.13.17/


    CustomLog /var/log/apache2/ooserver.newro.co.access.log combined
    ErrorLog /var/log/apache2/ooserver.newro.co.error.log
RewriteEngine on
RewriteCond %{SERVER_NAME} =ooserver.newro.co
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]


</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName ooserver.newro.co

#    SSLProxyEngine on
#    SSLProxyVerify none
#    SSLProxyCheckPeerCN off
#    SSLProxyCheckPeerName off
#    SSLProxyCheckPeerExpire off

ProxyVia On
ProxyRequests Off
ProxyPreserveHost on

    ProxyPass / "http://172.17.13.17/"
    ProxyPassReverse / "http://172.17.13.17/"

    <IfModule mod_headers.c>
        RewriteEngine On
        SetEnvIf Host "^(.*)$" THE_HOST=$1
        RequestHeader set X-Forwarded-Proto "https"
        ProxyAddHeaders Off
    </IfModule>

    CustomLog /var/log/apache2/ooserver.newro.co.access.log combined
    ErrorLog /var/log/apache2/ooserver.newro.co.error.log

SSLCertificateFile /etc/letsencrypt/live/ooserver.newro.co/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/ooserver.newro.co/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf

</VirtualHost>
</IfModule>

Troubleshot

If the rabbitmq-server doesn't start and in /var/log/rabbitmq/startup_log you re getting the following error:

ERROR: epmd error for host <hostname>: address (cannot connect to host/port)

edit the /etc/hosts file as follow:

127.0.0.1       localhost
127.0.0.1       <hostname>
<private.IP.address>    <hostname> <hostname>.defaultdomain

File recovery

In the event that you need to recover a file that was edited by OnlyOffice but for some reason can no longer be written back to the location/downloaded etc., it is possible to perform a manual recovery of a file.

The first challenge is identifying the file; the chances are that if it is a file experiencing issues you'll find it in the logs, most likely in a current or older /var/log/onlyoffice/documentserver/docservice/out.log; if you search by username this may reveal the document ID, a 10 digit number; this number corresponds to the file cache location subfolder in /var/lib/onlyoffice/documentserver/App_Data/cache/files/. If this folder exists then within it is a file "Editor.bin", which is a binary state "dump" used by OnlyOffice while the file is open. Take a copy of the file to temp in case something cleans it up before you can complete the next step.

Now in Nextcloud create a new blank document (not sure if it has to be the same type, it's possible the Editor.bin file contains that info) and then immediately check for a newly created folder in /var/lib/onlyoffice/documentserver/App_Data/cache/files/. Having identified the folder, carry out these commands on the OnlyOffice server:

 cp /var/lib/onlyoffice/documentserver/App_Data/cache/files/<mynewdocid>/Editor.bin /var/lib/onlyoffice/documentserver/App_Data/cache/files/<mynewdocid>/Editor.bin.old
 cp /mytemplocation/editor.bin /var/lib/onlyoffice/documentserver/App_Data/cache/files/<mynewdocid>/Editor.bin

Now switch back to your browser and reload the OnlyOffice tab showing your new blank document. The content of the recovered document should load.