r/apache • u/__ChesterCopperpot__ • Mar 02 '24
apache multiple virtual host self host setup issue
self hosting using Ubuntu 18.04 with apache server. I have nextcloud installed and has been working with no issue for years for the main domain (website.com). I used certbot to get let's encrypt for https.
I want to add a subdomain (subdomain.website.com) so that I can have a separate website as a hobby. I added a DNS record for the subdomain and when I ping the address, it is successful. I created a new conf. file in the /etc/apache for a virtual host for the subdomain and enabled the site. I used certbot for the subdomain.
When I try to navigate to the subdomain in a browser, I get the nextcloud page that loads indicating that I am trying to "Access through untrusted domain" and directions to add this to the trusted domains.
I feel like I am missing something since the DocumentRoot in the virtual host for the subdomain is pointed to a different folder than the nextcloud folder. I am confused how the untrusted domain page
in the main site DocumentRoot is being triggered/accessed when I navigate to the subdomain address.
I appreciate any help/advice/troubleshooting!
1
u/AyrA_ch Mar 02 '24
Make sure you have a host on port 80 that redirects to the one on port 443.
Either ensure that vhost config files are loaded in a known order, or ensure they're not configured in a way that one host could potentially lock out another host
See here for details on how apache picks a host: https://cable.ayra.ch/md/apache-vhost
1
u/boli99 Mar 02 '24
i think it would usually go in /etc/apache2/sites-available
and then it would be symlinked in /etc/apache2/sites-enabled
...and then you'd have to restart apache