Internal Server Error, oh no!

So my nextcloud server was working fine up until I switched domain names. I changed the domain on /etc/hosts, did changes for the other services I run like AdGuardHome and Jellyfin, also generated new certificates for the new domain and everything works fine on the web side but nextcloud started acting strange.

I am not able to log in and as soon as it logs in I get the Internal Server Error screen. Upon changing the debug from false to true in the config.php, I see the following output:

Technical details

  • Remote Address: 192.168.1.6
  • Request ID: 2JDYSXfB6WH9tiEmOQHp
  • Type: RuntimeException
  • Code: 0
  • Message: OpenSSL reported a problem
  • File: /var/www/nextcloud/lib/private/Authentication/Token/PublicKeyTokenProvider.php
  • Line: 462

Trace

#0 /var/www/nextcloud/lib/private/Authentication/Token/PublicKeyTokenProvider.php(106): OC\Authentication\Token\PublicKeyTokenProvider->newToken()
#1 /var/www/nextcloud/lib/private/Authentication/Token/Manager.php(53): OC\Authentication\Token\PublicKeyTokenProvider->generateToken()
#2 /var/www/nextcloud/lib/private/User/Session.php(650): OC\Authentication\Token\Manager->generateToken()
#3 /var/www/nextcloud/lib/public/AppFramework/Db/TTransactional.php(45): OC\User\Session->OC\User\{closure}()
#4 /var/www/nextcloud/lib/private/User/Session.php(648): OC\User\Session->atomic()
#5 /var/www/nextcloud/lib/private/Authentication/Login/CreateSessionTokenCommand.php(48): OC\User\Session->createSessionToken()
#6 /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php(22): OC\Authentication\Login\CreateSessionTokenCommand->process()
#7 /var/www/nextcloud/lib/private/Authentication/Login/CompleteLoginCommand.php(30): OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
#8 /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php(22): OC\Authentication\Login\CompleteLoginCommand->process()
#9 /var/www/nextcloud/lib/private/Authentication/Login/LoggedInCheckCommand.php(41): OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
#10 /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php(22): OC\Authentication\Login\LoggedInCheckCommand->process()
#11 /var/www/nextcloud/lib/private/Authentication/Login/EmailLoginCommand.php(51): OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
#12 /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php(22): OC\Authentication\Login\EmailLoginCommand->process()
#13 /var/www/nextcloud/lib/private/Authentication/Login/UidLoginCommand.php(36): OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
#14 /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php(22): OC\Authentication\Login\UidLoginCommand->process()
#15 /var/www/nextcloud/lib/private/Authentication/Login/UserDisabledCheckCommand.php(39): OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
#16 /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php(22): OC\Authentication\Login\UserDisabledCheckCommand->process()
#17 /var/www/nextcloud/lib/private/Authentication/Login/PreLoginHookCommand.php(34): OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
#18 /var/www/nextcloud/lib/private/Authentication/Login/Chain.php(90): OC\Authentication\Login\PreLoginHookCommand->process()
#19 /var/www/nextcloud/core/Controller/LoginController.php(326): OC\Authentication\Login\Chain->process()
#20 /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php(208): OC\Core\Controller\LoginController->tryLogin()
#21 /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php(114): OC\AppFramework\Http\Dispatcher->executeController()
#22 /var/www/nextcloud/lib/private/AppFramework/App.php(161): OC\AppFramework\Http\Dispatcher->dispatch()
#23 /var/www/nextcloud/lib/private/Route/Router.php(302): OC\AppFramework\App::main()
#24 /var/www/nextcloud/lib/base.php(1003): OC\Route\Router->match()
#25 /var/www/nextcloud/index.php(24): OC::handleRequest()
#26 {main}

I didn’t want to do it but after scouring the web for days and doing lots of debugging with ChatGPT, I even tried reinstalling PHP and Nextcloud again but the issue still persists.

This is where it gets interesting, I believe while in the process of changing domain and creating the SSL certificates using letsencrypt, I might have accidentally removed /etc/ssl folder. I found out that it had keys and such which caused other problems like not being able to download updates or install repositories since my Debian Server couldn’t verify as it didn’t have the certificates.

I was able to restore (I hope everything) since everything else is working fine but I still believe that since the problem with nextcloud is related to OpenSSL not being able to generate Certs, it may be linked to that problem.

I don’t want to set my server again cause is a pain in the butt to get everything back to how it was. So many services, scripts, settings all need to be reconfigured. I’ve already lost my configuration on nextcloud. I had made a backup of /nextcloud/core folder, I wanted to do the full folder but it didn’t allow me to copy it, I didn’t look into it much but do tell me if anything usefull can be used from the core folder I made backup of. I was using custom backgrounds and favicon, symbols.

Nextcloud Server version:

  • 30.0.4
    Operating system and version:
  • Debian 12
  • Web server and version:
  • Apache/2.4.62
    PHP version:
  • 8.3
    Is this the first time you’ve seen this error?:
  • Yes
    When did this problem seem to first start?
  • When I changed the domain name

Important is the data/ folder, and the config/ folder along with the database.

Regarding ssl, it can be helpful to test your ssl config from outside with ssllabs.com.

Before that, there should be another output stating the OpenSSL issue, it should be something like

Something is wrong with your openssl setup: …

Can you check if you find something there (there meaning your nextcloud.log that should be in your data directory)?

Also, random thought, did you change anything else in your config? Especially the instance id?

2 Likes

Thanks for the reply

This is what was printed in the debug

Message: OpenSSL reported a problem
File: /var/www/nextcloud/lib/private/Authentication/Token/PublicKeyTokenProvider.php
Line: 462

Trace
#0 /var/www/nextcloud/lib/private/Authentication/Token/PublicKeyTokenProvider.php(106): OC\Authentication\Token\PublicKeyTokenProvider->newToken()
#1 /var/www/nextcloud/lib/private/Authentication/Token/Manager.php(53): OC\Authentication\Token\PublicKeyTokenProvider->generateToken()
#2 /var/www/nextcloud/lib/private/User/Session.php(650): OC\Authentication\Token\Manager->generateToken()
#3 /var/www/nextcloud/lib/public/AppFramework/Db/TTransactional.php(45): OC\User\Session->OC\User\{closure}()
#4 /var/www/nextcloud/lib/private/User/Session.php(648): OC\User\Session->atomic()
#5 /var/www/nextcloud/lib/private/Authentication/Login/CreateSessionTokenCommand.php(48): OC\User\Session->createSessionToken()
#6 /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php(22): OC\Authentication\Login\CreateSessionTokenCommand->process()
#7 /var/www/nextcloud/lib/private/Authentication/Login/CompleteLoginCommand.php(30): OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
#8 /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php(22): OC\Authentication\Login\CompleteLoginCommand->process()
#9 /var/www/nextcloud/lib/private/Authentication/Login/LoggedInCheckCommand.php(41): OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
#10 /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php(22): OC\Authentication\Login\LoggedInCheckCommand->process()
#11

There are more lines, tell me if you need them

For some reason my nextcloud logs where empty that were defined in the .conf so I checked both apache2 logs and also found the nextcloud log somewhere, this is the main error I found and I don’t remember which log does it belong to

[Sun Dec 22 00:00:02.175438 2024] [ssl:warn] [pid 39081:tid 39081] AH01909: <my_old_domain>:443:0 server certificate does NOT include an ID which matches the server name

I didn’t make any other changes in the config.php, except the domain, here you can see


<?php
$CONFIG = array (
  'instanceid' => 'oc***REDACTED***',
  'passwordsalt' => '***REDACTED***',
  'secret' => '***REDACTED***',
  'trusted_domains' => 
  array (
    0 => '<CHANGED_THIS_TO_NEW_DOMAIN>:9009',
  ),
  'datadirectory' => '/mnt/Repository/Nextcloud',
  'dbtype' => 'mysql',
  'version' => '30.0.2.2',
  'overwrite.cli.url' => 'https://<CHANGED_THIS_TO_NEW_DOMAIN>:9009',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => '***REDACTED***',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => '<redacted>',
  'mail_domain' => 'gmail.com',
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_smtpport' => '465',
  'mail_smtpauth' => 1,
  'mail_smtpname' => '<redacted>',
  'mail_smtppassword' => '<redacted>',
  'maintenance_window_start' => 0,
  'defaultapp' => 'files',
  'default_phone_region' => 'IN',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => 'true',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 0,
  'app_install_overwrite' => 
  array (
    0 => 'imageconverter',
  ),
  'debug' => true,
);

The apache vhost, you need to adjust to the new domain name as well, and link the new letsencrypt-certificate.