Follow the instructions at: How to connect to the Nextcloud Box with SSH
To install a Let's Encrypt SSL certificate, type:
$ sudo nextcloud.enable-https lets-encrypt
If you'd rather use a self-signed certificate, you can type:
$ sudo nextcloud.enable-https self-signed