Fresh install of 16.0 on FreeBSD creates admin login redirect loop

Hi All, I am trying to get a freshly installed Nextcloud 16 system running inside a freebsd jail. Details below, I have tried a number of things which have fixed other people’s redirect loop issue to no avail and so I am seeking some extra help. Thanks in advance.

Nextcloud version: 16.0 (Freebsd Packages)
Operating system and version: FreeBSD 11.2-STABLE (jail)
nginx version: nginx/1.16.0
php73

After the initial setup form is submitted, I get into a redirect loop and I cannot login to my newly installed nextcloud instance. The directories in the data directory are created and the database is populated so the install has ‘succeeded’.

Steps to replicate it:

  1. Install Nextcloud 16 and pre-requsite packages from freebsd pkg system
  2. Submit setup form
  3. Try to login

I cannot login to the site to retrieve any logs unfortunately.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!) - I have added some extra variables during debugging as per https://github.com/nextcloud/server/issues/10885 and https://github.com/nextcloud/server/issues/13431

<?php
$CONFIG = array (
  'instanceid' => 'ochqfvkpbwxv',
  'passwordsalt' => 'FTsYJZNDrVBUEp9ADZaNiYIq4cJXgm',
  'secret' => 'Yf1Z2abQR0ohL+8g2vuQhfdk80KcMptydF0+K7nqmjx2cMXP',
  'trusted_domains' => 
  array (
    0 => 'nextcloud.xxx.biz',
  ),
  'trusted_proxies' => array('192.168.1.0/24','127.0.0.1'), 
  'datadirectory' => '/mnt/nextcloud',
  'dbtype' => 'mysql',
  'version' => '16.0.0.9',
  'overwrite.cli.url' => 'https://nextcloud.xxx.biz',
  'overwritehost' => 'nextcloud.xxx.biz',
  'overwriteprotocol' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'ncuser',
  'dbpassword' => 'xxx',
  'installed' => true,
  'maintenance' => false,
);

The output of your Apache/nginx/system log in /var/log/____: No errors in these files. Pasting the last few lines of access.log where it redirects

1.1.1.1 - - [03/May/2019:02:03:18 +1000] "POST /login HTTP/2.0" 303 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"
1.1.1.1 - - [03/May/2019:02:03:18 +1000] "GET /apps/files/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/74.0.3729.108 Chrome/74.0.3729.108 Safari/537.36"

It can easily happen if you manage redirects in your apache-config and .htaccess. Perhaps there could be some default redirect somewhere. If you have no clue, it sometimes can help to run your webserver in debug mode, this will certainly show the error but it will give you a lot of information. Perhaps there is some specific logging you could enable regarding redirects.

I actuall fixed it by downloading the fresh nextcloud install directly and used that as my webroot.
This leads me to believe it is something specific with the FreeBSD port/package.