Installing Collabora Online on Linux to Enable Office Online Editing for NextCloud

Publish: 2018-08-14 | Modify: 2019-04-15

NextCloud can achieve online editing of Office documents through plugins, but it depends on the Collabora Online service. Here are the steps to set it up.

NextCloud Logo

Deploy Collabora Online Service

Collabora Online provides multiple platforms and installation methods. This article uses the Linux Docker method for one-click deployment.

Install Docker on CentOS

# Install Docker
yum -y install docker
# Start Docker
service docker start
# Enable Docker to start on boot
systemctl enable docker

Deploy Collabora Online with Docker

# Deploy Collabora Online
docker pull collabora/code
# Run Collabora Online
docker run -t -d -p 127.0.0.1:9980:9980 -e "domain=<your-dot-escaped-domain>" \
        -e "username=admin" -e "password=S3cRet" --restart always --cap-add MKNOD collabora/code

Note that <your-dot-escaped-domain> refers to the WOPI host, which is the domain name used by your NextCloud. Multiple domain names can be separated by |, and you need to use double backslashes in the command line because the shell will escape the first one, while the domain parameter will use regular expressions.

For example, if your NextCloud domain is https://cloud.ttt.sh/, the command you should enter is as follows:

docker run -t -d -p 127.0.0.1:9980:9980 -e "domain=cloud\\.ttt\\.sh" \
        -e "username=admin" -e "password=S3cRet" --restart always --cap-add MKNOD collabora/code
  • username: the username you want to set
  • password: the password you want to set

Please adjust the account and password according to your needs. If there is no error, the installation should be successful. Enter the command netstat -apn|grep '9980' and if you see the screenshot below, it means Collabora Online is running properly.

Netstat

Set up Nginx Reverse Proxy for Collabora Online

Although Collabora Online was successfully installed in the previous step, it can only be accessed within the intranet. If you need to provide services in a public network, you can use Nginx reverse proxy. Here is an example of Nginx reverse proxy configuration from Xiaoz:

server
    {
    listen 443 ssl http2;
    #listen [::]:443 ssl http2;
    # certs sent to the client in SERVER HELLO are concatenated in ssl_certificate
    ssl_certificate /data/ssl/ttt.sh.crt;
    ssl_certificate_key /data/ssl/ttt.sh.key;
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:50m;
    ssl_session_tickets off;

    # intermediate configuration. tweak to your needs.
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
    ssl_prefer_server_ciphers on;
    # OCSP Stapling ---
    # fetch OCSP records from URL in ssl_certificate and cache them
    ssl_stapling on;
    ssl_stapling_verify on;

    server_name     office.ttt.sh;
    # static files
    location ^~ /loleaflet {
        proxy_pass https://localhost:9980;
        proxy_set_header Host $http_host;
    }

    # WOPI discovery URL
    location ^~ /hosting/discovery {
        proxy_pass https://localhost:9980;
        proxy_set_header Host $http_host;
    }

    # main websocket
    location ~ ^/lool/(.*)/ws$ {
        proxy_pass https://localhost:9980;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $http_host;
        proxy_read_timeout 36000s;
    }

    # download, presentation and image upload
    location ~ ^/lool {
        proxy_pass https://localhost:9980;
        proxy_set_header Host $http_host;
    }

    # Admin Console websocket
    location ^~ /lool/adminws {
        proxy_pass https://localhost:9980;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $http_host;
        proxy_read_timeout 36000s;
    }

}
server
{
    listen 80;
    server_name office.ttt.sh;
    rewrite ^(.*) https://office.ttt.sh$1 permanent;
}

Afterwards, you can access https://<CODE-domain>/loleaflet/dist/admin/admin.html to enter the Collabora Online control panel. At this point, the Collabora Online service has been successfully deployed.

Collabora Online Control Panel

NextCloud Configuration

In the NextCloud admin panel, go to "Apps" and find the Collabora Online plugin to enable it. Then, go to "Settings" - "Online Assistance" and enter the domain name of Collabora Online, as shown in the screenshot below.

NextCloud Settings

Finally, you can open Office documents in NextCloud and edit them online, as shown in the screenshot below.

Online Editing

Summary

Collabora Online not only provides online document editing for NextCloud, but also enables Office preview for Seafile. It is worth mentioning that Collabora Online consumes a lot of memory, especially when multiple people are editing documents simultaneously. Therefore, it is recommended to deploy Collabora Online with at least 4GB of memory.

Parts of this article are referenced from: Collabora Online Development Edition (CODE)


Comments