← Archive

Install a custom SSL (Tailscale) certificate on Nextcloud (VM)

Archived post · originally published · may be out of date

Linux · #Linux #Nextcloud #Tailscale #Ubuntu


Intro

Nextcloud is a beast of an application that can be deployed in numerous ways but the community has mainly standardized on deploying Nextcloud with Let's Encrypt in a docker container. For my own reasons, I have decided on deploying Nextcloud in a VM instead, specifically the Hansson IT Nextcloud VM (which is a highly customized self-deploying VM of Nextcloud) but I ran into some problems when I attempted to install my own supplied SSL certificate, mainly due to a lack of documentation. Nextcloud uses Apache HTTP Server and as a result you need to configure Apache to work with your custom SSL certificate.

Guide

  1. Obtain a SSL certificate and install on your Nextcloud VM
    1. In my case I am using Tailscale because I want my application accessible only within my Tailnet -> sudo tailscale cert [MACHINE NAME] to create my custom certificate.
    2. The certificate file created by Tailscale is a .crt and a .key pair but I had no issues replacing the default .pem and .key used by Apache
  2. Locate and modify the Apache nextcloud_tls_domain_self_signed.conf file to use your new certificate -> sudo nano /etc/apache2/sites-available/nextcloud_tls_domain_self_signed.conf
    1. In my case, the file I had to modify was the nextcloud_http_domain_self_signed.conf file created by Nextcloud VM located in the /etc/apache2/sites-available folder (your filename may vary)
    2. At the very bottom of the file you will see the title ### LOCATION OF CERT FILES ### where you will enter the path of your new certificate files
### LOCATION OF CERT FILES ###

SSLCertificateFile /home/ncadmin/certificates/MY-CERTIFICATE.crt

SSLCertificateKeyFile /home/ncadmin/certificates/MY-CERTIFICATE.key
  1. Finally, restart Apache and test
    1. Become root -> sudo -i
    2. Then restart Apache -> service apache2 restart

If everything worked, when you navigate to your Nextcloud instance there should be no HTTPS errors:

Nextcloud-ssl-1