07/03/2018

Installer collabora office

Collabora office est un equivalent de google doc pour nextcloud. Je l’ai installé dans un conteneur lxc avec un reverse proxy nginx. Je l’ai testé sur un debian et un ubuntu

source : https://help.nextcloud.com/t/howto-install-collabora-online-on-ubuntu-16-04-without-docker/5014/208

We are using LXC containers, so running Docker image in LXC container is not an option. So here is how to run Collabora online directly on Ubuntu 16.04.

I used scripts from this repo (they are used to provision Docker container btw) GitHub 87 CollaboraOnline/Docker-CODE

Docker-CODE - Dockerfile and scripts to generate CODE Docker image

git clone https://github.com/CollaboraOnline/Docker-CODE.git

cd Docker-CODE/scripts
sh install-libreoffice.sh

Bug libpng12… add to enf of /etc/apt/sources.list

ubuntu :

deb http://security.ubuntu.com/ubuntu xenial-security main

source pour ubuntu : https://packages.ubuntu.com/xenial/amd64/libpng12-0/download

debian :

deb http://ftp.fr.debian.org/debian jessie main 

source pour debian : https://packages.debian.org/fr/jessie/amd64/libpng12-0/download

Created a service to autostart collabora on startup from second script start-libreoffice.sh

cp start-libreoffice.sh /opt

Add file :

vim /etc/systemd/system/office.service
[Unit]
Description=Start LibreOffice service

[Service]
Type=oneshot
ExecStart=/bin/bash /opt/start-libreoffice.sh

[Install]
WantedBy=multi-user.target
systemctl start office.service
systemctl enable office.service
vim /etc/loolwsd/loolwsd.xml
<wopi desc="Allow/deny wopi storage. Mutually exclusive with webdav." allow="true">
    <host desc="Regex pattern of hostname to allow or deny." allow="true">nextcloud\.domain\.com</host>
    <max_file_size desc="Maximum document size in bytes to load. 0 for unlimited." type="uint">0</max_file_size>
    <!-- Cette addresse est nextcloud ok ! On s'en branle de savoir le conteneur collabora tout ça ! OK !!!! -->
</wopi>
systemctl restart loolwsd

Désactiver le https :

Dans le fichier /etc/loolwsd/loolwsd.xml

Remplacer true en false

<enable type="bool" desc="Controls whether SSL encryption is enable (do not disable for production deployment). If default is false, must first be compiled with SSL support to enable." default="true">false</enable>

Pour la conf nginx ya 2 manières (les autres de m’en branle les couilles et apache aussi !)

  1. Config nginx (sans ssl) :

Sur le fichier de config /etc/loolwsd/loolwsd.xml il faut mettre :

Et sur nextcloud il faut mettre l’adresse de collabora avec le port 9980

server {
    listen       80;
    server_name  collabora.example.com;

    # static files
    location ^~ /loleaflet {
        proxy_pass http://localhost:9980;
        proxy_set_header Host $http_host;
    }

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

    # Capabilities
    location ^~ /hosting/capabilities {
        proxy_pass http://localhost:9980;
        proxy_set_header Host $http_host;
    }

    # main websocket
    location ~ ^/lool/(.*)/ws$ {
        proxy_pass http://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 http://localhost:9980;
        proxy_set_header Host $http_host;
    }

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

  1. Config nginx (avec ssl sur le proxy)

Sur le fichier de config /etc/loolwsd/loolwsd.xml il faut mettre :

Et sur nextcloud il faut mettre l’adresse du proxy sans oublier le https et ne pas mettre de port

server {
    listen       443 ssl;
    server_name  collabora.example.com;

    ssl_certificate /path/to/ssl_certificate;
    ssl_certificate_key /path/to/ssl_certificate_key;

    # static files
    location ^~ /loleaflet {
        proxy_pass http://localhost:9980;
        proxy_set_header Host $http_host;
    }

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

    # Capabilities
    location ^~ /hosting/capabilities {
        proxy_pass http://localhost:9980;
        proxy_set_header Host $http_host;
    }

    # main websocket
    location ~ ^/lool/(.*)/ws$ {
        proxy_pass http://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 http://localhost:9980;
        proxy_set_header Host $http_host;
    }

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

source : https://www.collaboraoffice.com/code/#getting_set_up

And it works! Have fun