Nextcloud is broken after Installing ssl with lets encrypt

Hello Im having an issue on configuring nextcloud with ssl certificate:

Nextcloud version _19.0.3
Operating system and version _Ubuntu 20.04
Apache _Apache 2.4.25
PHP version _7.4

I was able to install and configure it correctly, below find the vhost config:
path: /etc/apache2/sites-available/nextcloud.conf

    <VirtualHost *:80>
            DocumentRoot "/var/www/nextcloud"
            ServerName adf.projectcloud.site
            ServerAlias www.adf.projectcloud.site
            ServerAdmin adf.contracts@gmail.com

            ErrorLog ${APACHE_LOG_DIR}/nextcloud.error
            CustomLog ${APACHE_LOG_DIR}/nextcloud.access combined

            <Directory /var/www/nextcloud/>
                Require all granted
                Options FollowSymlinks MultiViews
                AllowOverride All

               <IfModule mod_dav.c>
                   Dav off
               </IfModule>

            SetEnv HOME /var/www/nextcloud
            SetEnv HTTP_HOME /var/www/nextcloud
            Satisfy Any

           </Directory>

    RewriteEngine on
    RewriteCond %{SERVER_NAME} =adf.projectcloud.site [OR]
    RewriteCond %{SERVER_NAME} =www.adf.projectcloud.site
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
    </VirtualHost>

The Rewrite was added after installing ssl. So After Installing the ssl with lets encrypt my site was broken:
path: /etc/apache2/sites-available/nextcloud-le-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
        DocumentRoot "/var/www/nextcloud"
        ServerName adf.projectcloud.site
        ServerAlias www.adf.projectcloud.site
        ServerAdmin adf.contracts@gmail.com

        ErrorLog ${APACHE_LOG_DIR}/nextcloud.error
        CustomLog ${APACHE_LOG_DIR}/nextcloud.access combined

        <Directory /var/www/nextcloud/>
            Require all granted
            Options FollowSymlinks MultiViews
            AllowOverride All

           <IfModule mod_dav.c>
               Dav off
           </IfModule>

        SetEnv HOME /var/www/nextcloud
        SetEnv HTTP_HOME /var/www/nextcloud
        Satisfy Any

       </Directory>


Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/adf.projectcloud.site/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/adf.projectcloud.site/privkey.pem
</VirtualHost>
</IfModule>

The issue im facing:

The site doesnt respond after installing ssl. I am new in Linux System so please can u help me to solve these problem. I am hosting app on my own server.

The output of config.php file in /var/www/nextcloud/config/config.php

<?php
    $CONFIG = array (
      'instanceid' => '',
      'passwordsalt' => '',
      'secret' => '',
      'trusted_domains' => 
      array (
        0 => 'adf.projectcloud.site',
      ),
      'datadirectory' => '/var/www/nextcloud/data',
      'dbtype' => 'mysql',
      'version' => '19.0.3.1',
      'overwrite.cli.url' => 'http://adf.projectcloud.site',
      'dbname' => 'nextcloud',
      'dbhost' => 'localhost',
      'dbport' => '',
      'dbtableprefix' => 'oc_',
      'mysql.utf8mb4' => true,
      'dbuser' => 'user',
      'dbpassword' => 'password',
      'installed' => true,
      'allow_local_remote_servers' => true,
      'ldapIgnoreNamingRules' => false,
      'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
    );

Thanx in advance.

This line seems a bit... confusing:

Are there any other secure sites running on this same server?
If so, are any of them working now?
If not (and this is the first secure site), then you may need to allow HTTPS (port 443) in through the firewalls - just like HTTP (port 80) was allowed.

If you are unsure about what all is running and on which ports, then just show the output of:
apachectl -S

or it may require sudo
sudo apachectl -S

[whichever provides the output]

thank you, the result is:

VirtualHost configuration:
*:443                  adf.projectcloud.site (/etc/apache2/sites-enabled/nextcloud-le-ssl.conf:2)
*:80                   is a NameVirtualHost
         default server localhost (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost localhost (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost adf.projectcloud.site (/etc/apache2/sites-enabled/nextcloud.conf:1)
                 alias www.adf.projectcloud.site
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/run/apache2/" mechanism=default 
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

If you remove the http to https redirection, does the site still work in http ?

The problem was on my router,
I am using Forti guard before the server and i had to create some policy rules for opening the port 443. Thank you for helping me.

Best regards :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.