Both the domains work, but for the second domain I just can’t seen to figure out how to install a SSL certificate… For the first domain, I simply used certbot and it was set up in minutes. For the second domain I just wanted to do that again but it doesn’t work like that.
When I run the certbot setup I chose to install the SSL on the same virtual host as domain 1.
The error that certbot gives me is this: Could not find a VirtualHost for cloud.domain2.com in the Apache configuration Please create a VirtualHost with a ServerName matching cloud.domain2.com and try again
When I check the folder, the certificate is saved, but not installed/used.
What do I do now? I have a couple of possible solutions but I’m not sure these are correct or logical?
Remove all SSL certificates, rerun certbot and create a single SSL for both domain1 and domain2 (is this even possible?)
Create a VirtualHost for domain2 (Would this not create an entire new NextCloud instance, separate from my already running instance?)
I’d love to hear from you people, I’ve really found the forums to be super helpful so far!
I don’t think you have to delete the existing certificates, but you have to add both names to your VirtualHost (See example below) and run Certbot again. It should then create a certificate that is valid for both domains.
There’s no need to create a separate VirtualHost, as I already implied above, and no, a second VirtualHost wouldn’t create a second Nextcloud instance. Nextcloud is not really multi-tenant capable. And even if it were, Apache can’t change the Nextcloud config on its own and vice versa. However both have of course to be configured accordingly, in order to be able to work together:
Where do I add the virtualhost names? Is it located in the Nextcloud config.php file? Both domains are already in the trusted domains list so I think it might just be about adding both domains to the VirtualHost list.
Yes, as in my example. Just add the second domain name as a ServerAlias to your VirtualHost config, on a separate line, and try to run Certbot again. If it still doesn’t work, please post your entire Apache Virtualhost config and the exact command you used to run Certbot.
Hey bb77, thanks, that did work to some extend. Both domains now have an SSL so thats good.
But, something is still wrong, because both URL’s now show me this page… Any idea’s on how/where to fix this?
Hmm, not sure then. Maybe it is because both VirtualHosts are in the same config file… Usually Certbot automatically creates a second config file for the SSL config and adds redirect directives to the first one…
Example:
If your config file is named nextcloud.conf, Certbot will create a second config called nextcloud-le-ssl.conf
This would mean, that you now have two SSL configs for the same Server and Alias Names, but only the one in your first config file contains the additional directives for Nextcloud.
Maybe it would be easier to disable all of the existing configs, and start over with a fresh config.
Restart Apache and run certbot. Certbot will then create a file called nextcloud-le-ssl.conf, which already contains the directives from the first VirtualHost plus the SSL config. Leave those entries alone and only add the rest of your existing config under <VirtualHost *443> from the old config file to it:
Could you elaborate on that? Before I added the SSL at least both domains did work, but only one didn’t have an SSL. Now both have SSL, but don’t work sadly.
So before I start deleting all config files and starting over, I checked what is in the /etc/apache2/sites-available folder. These are the .conf files in there:
000-default.conf
nextcloud_http_domain_self_signed.conf
nextcloud_tls_domain_self_signed.conf
default-ssl.conf
nextcloud_tls_domain_self_signed-le-ssl.conf
Should I check any of these files before starting all over?
Your previous post helped me tremendously and I have marked it as the solution! Had a little struggle at first I soon realized I edited the wrong file. Thank you so much for this, very helpfull!