Nextcloud behind Apache Proxy causing 404 error

Nextcloud version (eg, 18.0.4:
Operating system and version (eg, Ubuntu 20.04):
Apache or nginx version (eg, Apache 2.4.25):
PHP version (eg, 7.4:

The issue you are facing: When I access my nextcloud from my network using 192.168.0.11, it works fine. I reach a log-in page and can upload and download files . However I want to have it accessible from the internet, so have set up a domain nc.example.com, and forwarded the dns… This works fine.

I have an apache proxy setup, listening on 433 and proxying to the internal nc instance, when I try and access from the outside sustem I get a 404 error… I basically copied and pasted the nc.example.com.conf file from another working proxy and tweaked the commands… The config.php might be a little more troublesome… I have read and attempted to tweak that with no success… I feel I am going in cirlcles, and am pretty sure that I am missing something glaringly obvious, but Google isnt my friend on this occasion
For clarity the proxy is 192.168.0.7, the server is 192.168.0.11 and the url I am using to access from outside is https://nc.example.com
Thanks in advance

Is this the first time you’ve seen this error? N)_:

Steps to replicate it:

  1. Log in using https://nc.example.com

The output of your Nextcloud log in Admin > Logging:
Error PHP Use of undefined constant com’ - assumed ‘com’’ (this will throw an Error in a future version of PHP) at /var/www/nextcloud/config/config.php#25

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'ocp48lunrefv',
  'passwordsalt' => 'RWwdWhQQJnbNg1o1ohxbeJ51tWUlni',
  'secret' => 'wVBVHJISeuzEArP1g+6zHvPt4zW5XWP+5HHK8Oy6iEmfODEB',
'trusted_proxies' => array('192.168.0.7'),
  'forwarded_for_headers' => array('HTTP_X_FORWARDED_FOR'),
  'trusted_domains' => 
  array (
    0 => '127.0.0.1',
    1 => 'nc.example.com',
    2 => '192.168.0.7',
    3 => '192.168.0.11',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '18.0.4.2',
   'overwrite.cli.url' => '/',
'htaccess.RewriteBase' => '/',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => ‘mypassword’,
  'installed' => true,
);

The output of your Apache/nginx/system log in /var/log/____:
Nothiing exciting
contents of nc.example.com.conf file from etc/apache2/sites-available/

<VirtualHost *:443>
        ServerAdmin webmaster@example.com
        ServerName nc.example.com
        SSLEngine On
        SSLProxyEngine On

SSLProtocol TLSv1.2
   SSLHonorCipherOrder On
   SSLCipherSuite EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EEC$

   Include /etc/letsencrypt/options-ssl-apache.conf

                ProxyRequests Off
                ProxyPreserveHost Off

        ProxyPass / http://192.168.0.11/
      ProxyPassReverse / http://192.168.0.11/

        ProxyPassReverseCookiePath /nextcloud /nextcloud
      SSLCertificateFile /etc/letsencrypt/live/nc.example.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/nc.example.com/privkey.pem
</VirtualHost>

To whoever tidied up te format, Thank you very much… I guess that shows my noobness :slight_smile:

Problem solved, needed
‘overwrite.cli.url’ => ‘http://nc.example.com/’,
‘overwriteprotocol’ => ‘https’,
‘overwritehost’ => ‘nc.example.com’,
adding to the config.php file

Thank you for this post, I was missing the overwritehost setting :slight_smile: