Nextcloud version : 23.0.4
Operating system and version : Debian GNU/Linux 10 (buster)
Apache or nginx version : Apache/2.4.38 (Debian)
PHP version : 8.0
Hello everyone,
I’m trying to access my nextcloud instance via a subdomain.
For now accessing using mydomain.com/nextcloud but cloud.mydomain.com redirects to the Apache2 Debian Default Page.
I’ve followed a few threads on this forum (mainly this one) to try and get it working, it helped me get further but I’m still missing a piece of the puzzle it seems.
I’ve tried many things for this project but also for other things on my server and so I know that my Virtual Hosts files are really messy and there must be something not right in there. I don’t know much about how to set them up properly and so I can’t find my mistake but I would really like a little bit of help to better understand what is going on whith them.
First I have 5 of them, which might not be ideal (?). A default one, one for my webpage (mydomain.com/index.html
) and one for nextcloud, then they all have an ssl version except for the NextCloud one.
The first default file (default.conf) :
<VirtualHost *:80>
ServerName cloud.mydomain.com
ServerAlias www.mydomain.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
Options -FollowSymlinks
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mydomain.com [OR]
RewriteCond %{SERVER_NAME} =cloud.mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
SSL version (default-le-ssl.conf) :
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName cloud.mydomain.com
ServerAlias www.mydomain.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
Options -FollowSymlinks
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLCertificateFile /etc/letsencrypt/live/cloud.mydomain.com-0001/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/cloud.mydomain.com-0001/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
For my website (on www.mydomain.com/index.html) (001-mydomain.conf) :
<VirtualHost *:80>
Redirect permanent / https://mydomain.com
</VirtualHost>
SSL version (001-mydomain-ssl.conf) :
<VirtualHost *:443>
ServerAdmin webmaster@localhost
Servername mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /var/www/html/mydomain
<Directory "/var/www/html/mydomain/">
Options -Indexes
Options +FollowSymlinks
<Limit PUT DELETE OPTIONS CONNECT TRACK>
Order deny,allow
Deny from all
</Limit>
<Files .htaccess>
Order allow,deny
Deny from all
</Files>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
</Directory>
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
</IfModule>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLProxyengine on
SSLProtocol -ALL -TLSv1 -TLSv1.1 +TLSv1.2
SSLHonorCipherOrder On
SSLCompression off
SSLSessionTickets off
ErrorDocument 400 /error/error_400.html
SSLCertificateFile /etc/letsencrypt/live/mydomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
Then, the one for nextcloud :
Alias /nextcloud "/var/www/nextcloud/"
#ServerName cloud.mydomain.com
#DocumentRoot /var/www/nextcloud
#ErrorLog /var/log/apache2/cloud.mydomain.com-error.log
#CustomLog /var/log/apache2/cloud.mydomain.com-access.log common
<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All
#Require all granted
#AllowOverride All
#Options FollowSymLinks MultiViews
<IfModule mod_dav.c>
Dav off
</IfModule>
<IfModule mod_headers.c>
Header set Referrer-Policy no-referrer
Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"
</IfModule>
SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud
</Directory>
Redirect 301 /.well-known/carddav /nextcloud/remote.php/dav
Redirect 301 /.well-known/caldav /nextcloud/remote.php/dav
Redirect 301 /.well-known/webfinger "/nextcloud/index.php/.well-known/webfinger"
Redirect 301 /.well-known/nodeinfo "/nextcloud/index.php/.well-known/nodeinfo"
And finally the config.php file (nextcloud/config/config.php) :
<?php
$CONFIG = array (
'instanceid' => 'NNNNNNNNNNNNNNNNNNNNNN',
'passwordsalt' => 'NNNNNNNNNNNNNNNNNNNNNN',
'secret' => 'NNNNNNNNNNNNNNNNNNNNNN',
'trusted_domains' =>
array (
0 => 'mydomain.com',
1 => 'cloud.mydomain.com',
),
'default_phone_region' => 'FR',
'datadirectory' => '/var/www/nextcloud/data',
'dbtype' => 'mysql',
'version' => '23.0.4.1',
'overwrite.cli.url' => 'https://mydomain.com/nextcloud',
'htaccess.RewriteBase' => '/nextcloud',
'dbname' => 'nextcloud',
'dbhost' => 'localhost',
'dbport' => '',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'nextcloud',
'dbpassword' => 'NNNNNNNNNNNNNNNNNNNNNN',
'installed' => true,
'memcache.local' => 'OC\\Memcache\\APCu',
'mail_smtpmode' => 'smtp',
'mail_sendmailmode' => 'smtp',
'mail_smtpauthtype' => 'LOGIN',
'mail_smtpauth' => 1,
'has_rebuilt_cache' => true,
'mail_smtpport' => '587',
'mail_smtpname' => 'myemail@email.com',
'mail_smtppassword' => 'NNNNNNNNNNNNNNNNNNNNNN',
'mail_smtpsecure' => 'tls',
'mail_smtphost' => 'smtp-relay.sendinblue.com',
'maintenance' => false,
'theme' => '',
'loglevel' => 2,
);
The DNS record part seem to be ok since I get the debian default page.
I apologize for the lengthy post but I am really not sure where the problem can come from.
Thank you to anyone who takes the time to read that and provide some pointer on finding my mistake.
Have a nice day everyone.