Nextcloud VM behind reverse proxy - 404 Errors

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 22.2.0.2
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04.3 LTS
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.41
PHP version (eg, 7.4): 7.4.3

The issue you are facing:
When trying to access Nextcloud via reverse proxy, it redirects me to the static Nextcloud VM welcome page. Attempting to visit /login results in a “Not Found” error.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Install the Nextcloud VM from Hanssonit
  2. On a separate VM, install Caddy and configure a reverse proxy to the Nextcloud VM
  3. Attempt to log in to Nextcloud through the reverse proxy

The output of your Nextcloud log in Admin > Logging:

N/A

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

<?php
$CONFIG = array (
  'passwordsalt' => 'REDACTED',
  'secret' => 'REDACTED',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => '192.168.20.101',
    2 => 'nextcloud',
    3 => 'REDACTED-PUBLIC-DOMAIN',
  ),
  'trusted_proxies' => 
  array (
    0 => '192.168.20.102',
  ),
  'datadirectory' => '/mnt/ncdata',
  'dbtype' => 'pgsql',
  'version' => '22.2.0.2',
  'dbname' => 'nextcloud_db',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'ncadmin',
  'dbpassword' => 'REDACTED',
  'installed' => true,
  'instanceid' => 'REDACTED',
  'upgrade.disable-web' => true,
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'loglevel' => '2',
  'log.condition' => 
  array (
    'apps' => 
    array (
      0 => 'admin_audit',
    ),
  ),
  'mail_smtpmode' => 'smtp',
  'remember_login_cookie_lifetime' => '1800',
  'log_rotate_size' => '10485760',
  'trashbin_retention_obligation' => 'auto, 60',
  'versions_retention_obligation' => 'auto, 180',
  'activity_expire_days' => '120',
  'simpleSignUpLink.shown' => false,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => true,
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.5,
    'dbindex' => 0,
    'password' => 'REDACTED',
  ),
  'default_phone_region' => 'us',
  'logtimezone' => 'REDACTED',
  'htaccess.RewriteBase' => '/',
  'maintenance' => false,
);

The output of your Apache/nginx/system log in /var/log/apache2/error.log:

[Tue Nov 02 17:57:09.957993 2021] [proxy:error] [pid 8446:tid 139878520039168] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php7.4-fpm.sock (*) failed
[Tue Nov 02 17:57:09.958051 2021] [proxy_fcgi:error] [pid 8446:tid 139878520039168] [client 192.168.20.102:34594] AH01079: failed to make connection to backend: httpd-UDS

Full details:

My setup is a bit complicated due to the fact that I’m behind a CGNAT. I’m running the Nextcloud VM appliance from Hansonnit in Proxmox. Everything works locally. For remote access, I’m running a WireGuard server on a VPS that another VM connects to. This VM is also running Caddy. I have a public domain name that is pointing to the IP address of my VPS, which is configured to forward HTTP and HTTPS traffic to the Caddy VM via WireGuard.

So basically:
Remote Client > VPS > Caddy VM (192.168.20.102) > Nextcloud VM (192.168.20.101)

When I enter the domain into my browser, I get pointed to the static welcome page for the Nextcloud VM. Clicking the login link doesn’t take me to the login page, just back to the welcome page. Attempting to access /login manually just results in a Not Found error. I’ve tried several of the “overwrite” Nextcloud config options with no luck. Here’s my Caddyfile if that helps:

REDACTED-PUBLIC-DOMAIN

rewrite /.well-known/carddav /remote.php/dav
rewrite /.well-known/caldav /remote.php/dav

reverse_proxy 192.168.20.101

I’m not sure if this is a Caddy issue or a Nextcloud issue. I suspect that I’m missing something in the Nextcloud config, but I’m not sure what. Please let me know if there’s additional information I could provide.

Bump. Attached the apache2 error.log output which might be helpful.

Bump. In the /run/php/ directory, there is a php7.4-fpm-nextcloud.sock entry. Not sure why requests from the reverse proxy are getting pointed to php-7.4-fpm which doesn’t exist.

Bumpity bump…

Bump number 4…

Bump number 5…

Bump number 6…