# Configure storage zones controller for web app previews and editing using Collabora

Use Collabora Online to preview and edit supported Microsoft Office documents in the ShareFile web app when the files are stored in a customer-managed storage zone. Collabora runs separately from storage zones controller and uses the Web Application Open Platform Interface (WOPI) to access documents.

## Before you begin

* Use a dedicated host with administrator or `sudo` access, sufficient resources for your workload, and network access to download packages and container images. Check that no existing service uses the HTTPS port you plan to use.
* Confirm that you have an eligible ShareFile account and a configured storage zones controller. To enable editing, turn on [file versioning](https://docs.sharefile.com/en-us/sharefile/sharefile-app/sharefile-web/file-versioning) for your ShareFile account.
* Assign a DNS hostname to Collabora, such as `collabora.example.com`, and point it to your host or approved load balancer. Obtain a trusted TLS certificate for the hostname, including its intermediate certificate chain and matching private key.
* Allow the required browsers, storage zones controllers, and ShareFile services to reach Collabora over HTTPS on TCP port 443. Allow Collabora to reach the required storage zones controller and ShareFile endpoints over HTTPS. Restrict access to the networks required for your deployment.

## Choose an installation guide

Collabora runs in a Linux Docker container. The following platforms are supported:

| Platform                                                   | Installation guide                                                                                                                                                                                                                                                   |
| ---------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Ubuntu Server or Debian                                    | [Install Collabora on Ubuntu or Debian](https://docs.sharefile.com/en-us/sharefile/storage-zones-controller/6-0/install/collabora/ubuntu-debian)                                                                                                                     |
| Amazon Linux 2023                                          | [Install Collabora on Amazon Linux 2023](https://docs.sharefile.com/en-us/sharefile/storage-zones-controller/6-0/install/collabora/amazon-linux-2023)                                                                                                                |
| Red Hat Enterprise Linux (RHEL), Rocky Linux, or AlmaLinux | Install Docker Engine for your distribution, then follow [Deploy the Collabora container](https://docs.sharefile.com/en-us/sharefile/storage-zones-controller/6-0/install/collabora#deploy-the-collabora-container). The Amazon Linux package commands do not apply. |
| Windows Server                                             | [Install Collabora on Windows Server using WSL2](https://docs.sharefile.com/en-us/sharefile/storage-zones-controller/6-0/install/collabora/windows-server-wsl2)                                                                                                      |

## Deploy the Collabora container

Run these commands in Bash on the Linux host or inside Ubuntu on WSL2 after you install Docker Engine. The commands use Collabora Online Development Edition (CODE).

1. Set the hostnames for your environment. Use the hostname from the storage zones controller external address, without the scheme or path.

   ```bash
   export COLLABORA_HOST='collabora.example.com'
   export SZC_HOST='szc.example.com'
   export COLLABORA_IMAGE='collabora/code:latest'
   ```

2. Create the directories and copy your certificate chain and key into `/opt/collabora/certs` as `fullchain.pem` and `privkey.pem`. Restrict access to the private key.

   ```bash
   sudo install -d -m 0755 /opt/collabora/{certs,config,proofkeys}
   sudo chown root:root /opt/collabora/certs/{fullchain.pem,privkey.pem}
   sudo chmod 644 /opt/collabora/certs/fullchain.pem
   sudo chmod 600 /opt/collabora/certs/privkey.pem
   ```

3. For a new installation, generate the WOPI proof keys. Keep these files when you update or recreate the container. If keys already exist, reuse them instead of running the generation commands.

   ```bash
   sudo openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 \
     -out /opt/collabora/proofkeys/proof_key
   sudo openssl pkey -in /opt/collabora/proofkeys/proof_key \
     -pubout -out /opt/collabora/proofkeys/proof_key.pub
   sudo chown 1001:1001 /opt/collabora/proofkeys/{proof_key,proof_key.pub}
   sudo chmod 600 /opt/collabora/proofkeys/proof_key
   sudo chmod 644 /opt/collabora/proofkeys/proof_key.pub
   ```

4. Download the Collabora seccomp profile, which limits the system calls the container can make. Proceed only if the checksum matches.

   ```bash
   sudo curl -fsSL \
     https://raw.githubusercontent.com/CollaboraOnline/online/c5da9d06cafbda7b1a68cfad02019c1355188199/docker/cool-seccomp-profile.json \
     -o /opt/collabora/config/cool-seccomp-profile.json
   printf '%s  %s\n' \
     '0523d069558aab11de1617e1868f4ffeeb87645b32fb35bb97e9501de9e1892a' \
     '/opt/collabora/config/cool-seccomp-profile.json' | sha256sum --check
   ```

5. Next, follow only the HTTPS setup that matches your infrastructure:
   * [Option A: Use direct HTTPS](https://docs.sharefile.com/en-us/sharefile/storage-zones-controller/6-0/install/collabora#option-a-use-direct-https) if Collabora handles HTTPS for its hostname.
   * [Option B: Use an Nginx reverse proxy](https://docs.sharefile.com/en-us/sharefile/storage-zones-controller/6-0/install/collabora#option-b-use-an-nginx-reverse-proxy) if Nginx handles HTTPS for the Collabora hostname.

### Option A: Use direct HTTPS

1. Extract the leaf certificate and intermediate certificates into separate files. Install a copy of the private key that the container user can read.

   ```bash
   sudo openssl x509 -in /opt/collabora/certs/fullchain.pem \
     -out /opt/collabora/certs/cert.pem
   sudo awk '/-----BEGIN CERTIFICATE-----/ {n++} n>1 {print}' \
     /opt/collabora/certs/fullchain.pem | sudo tee /opt/collabora/certs/chain.pem >/dev/null
   sudo install -o 1001 -g 1001 -m 600 \
     /opt/collabora/certs/privkey.pem /opt/collabora/certs/key.pem
   ```

2. Start Collabora with HTTPS on port 443.

   ```bash
   sudo docker pull "$COLLABORA_IMAGE"
   sudo docker run -d --name collabora --restart always \
     -p 443:9980 \
     --security-opt seccomp=/opt/collabora/config/cool-seccomp-profile.json \
     -v /opt/collabora/proofkeys/proof_key:/etc/coolwsd/proof_key:ro \
     -v /opt/collabora/proofkeys/proof_key.pub:/etc/coolwsd/proof_key.pub:ro \
     -v /opt/collabora/certs/cert.pem:/etc/coolwsd/cert.pem:ro \
     -v /opt/collabora/certs/key.pem:/etc/coolwsd/key.pem:ro \
     -v /opt/collabora/certs/chain.pem:/etc/coolwsd/ca-chain.cert.pem:ro \
     --env "domain=${SZC_HOST//./\\.}" \
     --env "server_name=$COLLABORA_HOST" \
     --env 'extra_params=--o:net.proto=IPv4 --o:net.frame_ancestors=*.sharefile.com *.sharefile.eu *.securevdr.com' \
     "$COLLABORA_IMAGE"
   ```

Skip Option B and go straight to [Check the deployment](https://docs.sharefile.com/en-us/sharefile/storage-zones-controller/6-0/install/collabora#check-the-deployment).

### Option B: Use an Nginx reverse proxy

1. Install Nginx on the same Linux host or inside the same WSL2 distribution as Docker. Start Collabora with its HTTP port bound to loopback.

   ```bash
   sudo docker pull "$COLLABORA_IMAGE"
   sudo docker run -d --name collabora --restart always \
     -p 127.0.0.1:9980:9980 \
     --security-opt seccomp=/opt/collabora/config/cool-seccomp-profile.json \
     -v /opt/collabora/proofkeys/proof_key:/etc/coolwsd/proof_key:ro \
     -v /opt/collabora/proofkeys/proof_key.pub:/etc/coolwsd/proof_key.pub:ro \
     --env "domain=${SZC_HOST//./\\.}" \
     --env "server_name=$COLLABORA_HOST" \
     --env 'extra_params=--o:ssl.enable=false --o:ssl.termination=true --o:net.proto=IPv4 --o:net.frame_ancestors=*.sharefile.com *.sharefile.eu *.securevdr.com' \
     "$COLLABORA_IMAGE"
   ```

2. Add the following server block to a file included by Nginx. Use `/etc/nginx/sites-available/collabora` with a symlink in `sites-enabled` on Ubuntu or Debian, or `/etc/nginx/conf.d/collabora.conf` on Amazon Linux 2023. Replace the example hostname.

   ```nginx
   map $http_upgrade $collabora_connection_upgrade {
       default upgrade;
       '' close;
   }

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

       ssl_certificate /opt/collabora/certs/fullchain.pem;
       ssl_certificate_key /opt/collabora/certs/privkey.pem;
       ssl_protocols TLSv1.2 TLSv1.3;
       client_max_body_size 100m;

       location ^~ /cool/adminws {
           deny all;
       }

       location / {
           proxy_pass http://127.0.0.1:9980;
           proxy_http_version 1.1;
           proxy_set_header Host $http_host;
           proxy_set_header X-Forwarded-Proto https;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection $collabora_connection_upgrade;
           proxy_read_timeout 36000s;
           proxy_send_timeout 36000s;
           proxy_buffering off;
       }
   }
   ```

3. On Ubuntu or Debian, including Ubuntu on WSL2, enable the new site.

   ```bash
   sudo ln -s /etc/nginx/sites-available/collabora /etc/nginx/sites-enabled/collabora
   ```

4. Test and load the Nginx configuration.

   ```bash
   sudo nginx -t && sudo systemctl enable --now nginx && sudo systemctl reload nginx
   ```

### Check the deployment

Check that the container is running and both endpoints return HTTP 200 without certificate errors. If you deployed on Windows Server, [finish forwarding HTTPS to WSL2](https://docs.sharefile.com/en-us/sharefile/storage-zones-controller/6-0/install/collabora/windows-server-wsl2#forward-https-to-wsl2) before testing from outside the host.

```bash
sudo docker ps --filter name=collabora
curl -fsS -o /dev/null -w '%{http_code}\n' "https://$COLLABORA_HOST/hosting/discovery"
curl -fsS -o /dev/null -w '%{http_code}\n' "https://$COLLABORA_HOST/hosting/capabilities"
```

If a check fails, confirm that DNS resolves to the intended host, port 443 is reachable, and the certificate matches the hostname and includes its intermediate chain. Check `sudo docker logs --tail 100 collabora` and, if you use Nginx, its error log. If your private key is passphrase-protected, use a protected runtime copy that the service can read without prompting. Keep the original encrypted key and restrict access to the runtime copy.

## Configure storage zones controller

1. On the storage zones controller server, open `http://localhost/ConfigService/admin.aspx`.
2. If both **Enable Proxy** and **Trust system proxy egress filtering for discovery URLs** are enabled under **Networking** > **Proxy Status**, add the Collabora hostname to **Trusted discovery hosts** and save. Enter only the hostname, such as `collabora.example.com`, without the scheme, port, or path. Separate multiple hostnames with commas or semicolons. Do not use wildcards.
3. Select **Enable Preview** and choose **Collabora** as the preview provider.
4. Enter the Collabora HTTPS URL, such as `https://collabora.example.com`. Use the base URL, not the `/hosting/discovery` endpoint.
5. Enable document editing if needed, then save.
6. Open **Monitoring** and check **Document Previewer Server Connectivity**.
7. In the ShareFile web app, open a supported document stored in the customer-managed zone. Verify that the document previews and, if you enabled editing, that you can edit and save it. A successful discovery check does not verify end-to-end operation.

## Use a commercial Collabora Online deployment

This guide covers CODE. For a licensed container image, deployment instructions, or commercial support, [contact Collabora](https://www.collaboraonline.com/contact-us/). Before replacing CODE, back up your configuration and persistent files. If the licensed deployment uses a different HTTPS URL, update the URL in storage zones controller and verify previews and editing again.
