Issue Exposing Nextcloud Docker to Domain via Cloudflare Tunnel - "Class 'OCP\Server' Not Found" Fatal Error

Hello everyone,

I am currently trying to expose my Nextcloud Docker instance to a domain using Cloudflare Tunnel. The domain is properly configured, and the tunnel seems to be set up correctly. However, I am encountering a fatal error when accessing Nextcloud:

Fatal error: Uncaught Error: Class “OCP\Server” not found in /var/www/html/index.php:81

Stack trace:
#0 {main} thrown in /var/www/html/index.php on line 81.

Here is the configuration I have set up in config.php:

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'upgrade.disable-web' => true,
  'instanceid' => 'YOUR_INSTANCE_ID',
  'passwordsalt' => 'YOUR_PASSWORD_SALT',
  'secret' => 'YOUR_SECRET',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'YOUR_DOMAIN',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'pgsql',
  'version' => '30.0.2.2',
  'dbname' => 'nextcloud',
  'dbhost' => 'YOUR_DB_HOST',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'YOUR_DB_USER',
  'dbpassword' => 'YOUR_DB_PASSWORD',
  'installed' => true,
  'memories.exiftool' => '/var/www/html/custom_apps/memories/bin-ext/exiftool-amd64-glibc',
  'memories.vod.path' => '/var/www/html/custom_apps/memories/bin-ext/go-vod-amd64',
  'maintenance' => false,
  'overwrite.cli.url' => 'https://YOUR_DOMAIN',
);

System Details:

  1. Operating System (Manjaro Linux)

    • Kernel: 6.9.12-3-MANJARO
    • Type: Rolling release based on Arch Linux.
    • Architecture: x86_64
    • Preemptive Kernel: SMP PREEMPT_DYNAMIC
  2. PHP

    • Version: PHP 8.3.14
    • Zend Engine: v4.3.14
    • Non-Thread Safe (NTS)
  3. Docker

    • Version: 27.3.1
    • Build: ce1223035a

I have verified the Docker container logs and ensured that everything seems fine with the container setup. The Nextcloud instance runs smoothly locally but throws this error when accessed via the tunnel.

Has anyone encountered this issue before or have suggestions on how to resolve it? Any help would be appreciated!

Which image is this?

Please post your Compose file + use occ config: list system to get your real config.

[jazias@jazia-server ~]$ docker inspect nextcloud_app | grep ‘“Image”:’
“Image”: “sha256:9e0b6d71a2b449eae72f61aab9031c838cfb2d90a2973d27b5b67800869b41d5”,
“Image”: “nextcloud”,
[jazias@jazia-server ~]$ docker exec -u www-data nextcloud_app php occ config:list system
{
“system”: {
“htaccess.RewriteBase”: “/”,
“memcache.local”: “\OC\Memcache\APCu”,
“apps_paths”: [
{
“path”: “/var/www/html/apps”,
“url”: “/apps”,
“writable”: false
},
{
“path”: “/var/www/html/custom_apps”,
“url”: “/custom_apps”,
“writable”: true
}
],
“upgrade.disable-web”: true,
“instanceid”: “value”,
“passwordsalt”: “value”,
“secret”: “value”,
“trusted_domains”: [
“localhost”,
“192.168.1.100”,
“web.domanine”
],
“datadirectory”: “value”,
“dbtype”: “pgsql”,
“version”: “30.0.2.2”,
“dbname”: “value”,
“dbhost”: “value”,
“dbport”: “”,
“dbtableprefix”: “oc_”,
“dbuser”: “value”,
“dbpassword”: “value”,
“installed”: true,
“memories.exiftool”: “/var/www/html/custom_apps/memories/bin-ext/exiftool-amd64-glibc”,
“memories.vod.path”: “/var/www/html/custom_apps/memories/bin-ext/go-vod-amd64”,
“maintenance”: false,
“overwrite.cli.url”: “https://web.domanine”
}
}
[jazias@jazia-server ~]$

[jazias@jazia-server ~]$ docker exec -it nextcloud_app php -v
PHP 8.2.26 (cli) (built: Nov 21 2024 17:59:31) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.26, Copyright (c) Zend Technologies
with Zend OPcache v8.2.26, Copyright (c), by Zend Technologies
[jazias@jazia-server ~]$

Any update ?

Again, please post your Docker Compose file.

I suspect there is more than one thing going on. Though the area of code you’re hitting suggests brute force protection is kicking in, that’s not at all the error I’d expect unless something was very wrong with the installation.

Also, please check:

  • the container log while making the connection attempt (to confirm the HTTP transaction is reaching the correct container when you come in via the CF Tunnel)
  • your Nextcloud log