Use HTTPS with Ubuntu 22.04, apache, Nextcloud and Collabora(Docker)

My previous setup with HTTPS always failed on Nextcloud and Collabora.

When I saw the article Integrate Collabora Online with Nextcloud on Ubuntu without Docker by Xiao Guoan, I saw hope.

I did not use valid credentials for this article. If you want to use an authenticated SSL certificate, please refer to the above article.

I’m going to write this because I’ve seen some articles like those below.

At the bottom of the official website article is written Issue: Collabora Online doesn’t work with Encryption. Yes, this is currently unsupported.
Collabora + Nextcloud + Docker = Failure by @flkiwi
Collabora from snap install does not work via HTTPS by @michimartini


Also, I’ve seen other Docker configurations that maybe can work.

Mixed content error with Collabora CODE / Nextcloud / Traefik reverse proxy via docker-compose


My operating system uses Ubuntu 22.04.

This article uses the following settings and modifies them to suit your needs.

IP address:192.168.0.200
admin account:nextcloud
admin password:nextcloud
MySQL database:nextcloud
MySQL account:nextcloud
MySQL password:nextcloud
Collabora admin account:admin
Collabora admin password:admin

I won’t go into details. :sweat_smile:

Install Nextcloud and Collabora steps.

update and upgrade packages.

sudo apt -y update
sudo apt -y upgrade

Install Apache, MySQL, and Docker.

sudo apt -y install apache2 mysql-server docker docker.io

Install other packages

sudo apt -y install php zip libapache2-mod-php php-gd php-json php-mysql php-curl php-mbstring php-intl php-imagick php-xml php-zip php-bcmath php-gmp php-bz2 php-ldap php-smbclient php-apcu libmagickcore-6.q16-6-extra

Collabora Server by Docker(Please modify the account password by yourself)

sudo docker pull collabora/code
sudo docker run -t -d -p 127.0.0.1:9980:9980 --restart always -e “extra_params=–o:ssl.enable=false --o:ssl.termination=true” -e “username=admin” -e “password=admin” --cap-add MKNOD collabora/code

Start and set the bootup to run

sudo systemctl start apache2.service
sudo systemctl enable apache2.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service
sudo systemctl start docker.service
sudo systemctl enable docker.service

Set MySQL database, account, and password

sudo mysql -u root -p
CREATE DATABASE nextcloud;
CREATE USER ‘nextcloud’@‘localhost’ IDENTIFIED BY ‘nextcloud’;
GRANT ALL PRIVILEGES ON nextcloud.* TO ‘nextcloud’@‘localhost’;
FLUSH PRIVILEGES;
exit

Install Nextcloud

wget https://download.nextcloud.com/server/releases/latest-24.zip
unzip -q latest-24.zip
sudo mv nextcloud /var/www/html/
sudo chown -R www-data:www-data /var/www/html/nextcloud
sudo mkdir -p /var/log/apache2/nextcloud/
sudo sed -i ‘/^memory_limit =/s/=.*/= 512M/’ /etc/php/8.1/apache2/php.ini

Enable Apache modules.

sudo a2enmod rewrite headers env dir mime ssl proxy_http

Set Apache config for Nextcloud and Collabora.

sudo nano /etc/apache2/sites-available/nextcloud.conf

Alias / "/var/www/html/nextcloud/"

<Directory /var/www/html/nextcloud/>
  Require all granted
  AllowOverride All
  Options FollowSymLinks MultiViews

  <IfModule mod_dav.c>
    Dav off
  </IfModule>
</Directory>

<VirtualHost *:80>
   ServerName 192.168.0.200
   Redirect permanent / https://192.168.0.200/
</VirtualHost>
<VirtualHost *:443>
   ServerName 192.168.0.200
   DocumentRoot /var/www/html/nextcloud
   <IfModule mod_headers.c>
     Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
   </IfModule>
   <IfModule mod_rewrite.c>
     RewriteEngine on
     RewriteRule ^/\.well-known/carddav https://%{SERVER_NAME}/remote.php/dav [R=301,L]
     RewriteRule ^/\.well-known/caldav https://%{SERVER_NAME}/remote.php/dav [R=301,L]
     RewriteRule ^/\.well-known/webfinger https://%{SERVER_NAME}/index.php/.well-known/webfinger [R=301,L]
     RewriteRule ^/\.well-known/nodeinfo https://%{SERVER_NAME}/index.php/.well-known/nodeinfo [R=301,L]
   </IfModule>
  Options -Indexes

  # Encoded slashes need to be allowed
  AllowEncodedSlashes NoDecode

  # keep the host
  ProxyPreserveHost On

  # static html, js, images, etc. served from coolwsd
  # loleaflet/browser is the client part of Collabora Online
  ProxyPass           /loleaflet http://127.0.0.1:9980/loleaflet retry=0
  ProxyPassReverse    /loleaflet http://127.0.0.1:9980/loleaflet
  ProxyPass           /browser http://127.0.0.1:9980/browser retry=0
  ProxyPassReverse    /browser http://127.0.0.1:9980/browser

  # WOPI discovery URL
  ProxyPass           /hosting/discovery http://127.0.0.1:9980/hosting/discovery retry=0
  ProxyPassReverse    /hosting/discovery http://127.0.0.1:9980/hosting/discovery

  # Capabilities
  ProxyPass           /hosting/capabilities http://127.0.0.1:9980/hosting/capabilities retry=0
  ProxyPassReverse    /hosting/capabilities http://127.0.0.1:9980/hosting/capabilities

  # Main websocket
  ProxyPassMatch      "/cool/(.*)/ws$" ws://127.0.0.1:9980/cool/$1/ws nocanon

  # Admin Console websocket
  ProxyPass           /cool/adminws ws://127.0.0.1:9980/cool/adminws

  # Download as, Fullscreen presentation and Image upload operations
  ProxyPass           /cool http://127.0.0.1:9980/cool
  ProxyPassReverse    /cool http://127.0.0.1:9980/cool

</VirtualHost>

ErrorLog ${APACHE_LOG_DIR}/nextcloud/nextcloud_error.log
CustomLog ${APACHE_LOG_DIR}/nextcloud/nextcloud_access.log combined

Enable Apache sites.

sudo a2ensite default-ssl nextcloud

Reload and restart Apache.

sudo systemctl reload apache2.service
sudo systemctl restart apache2.service

Try to connect Collabora admin console.

https://192.168.0.200/browser/dist/admin/adminSettings.html
input account and password.

I will not write other basic installations. :sweat_smile:


Set Nextcloud admin, data folders, and MySQL by connecting to https://192.168.0.200/.


I don’t have the recommended apps installed.


If you don’t have Nextcloud Office installed, please install it.

Install and enable Nextcloud Office via Apps.


Set Nextcloud Office configuration on Office in Administration on Settings.

URL (and Port) of Collabora Online-server:https://192.168.0.200

#If you see “Saved with error: Collabora Online should use the same protocol as the server installation.”
#Don’t worry this will not affect Nextcloud Office.


If configured correctly, it will open successfully.

You can create or open a document, spreadsheet, or presentation.


written by bearchen :bear:

this would only in your dev environment, base on you setting, collabora will only allow you edit file from 192.168.0.200,