System details:
Linux 4.18.0-80.11.2.el8_0.x86_64 #1 SMP Tue Sep 24 11:32:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Docker image: nextcloud:17.0.1RC1
Docker version 19.03.4, build 9013bf583a
Apache/2.4.38 (Debian)
PHP 7.3.11 (cli) (built: Oct 25 2019 02:28:50) ( NTS )
The issue you are facing:
Fresh install and configuration of Nextcloud 17.0.1RC1, official nextcloud docker container, is stuck in 302 loop after webroot and rewritebase are configured in config.php.
Is this the first time you’ve seen this error? (Y/N): N - been an issue since first attempted to reverse proxy using path and not root address proxy in version 13.
Worked around by having softlink matching path name in www directory pointing at itself (a retarded ducttape solution).
Steps to replicate it:
- Install nextcloud docker:
docker run -d -v nextcloud:/var/www/html/config -p 8080:80 nextcloud:17.0.1RC1
- Run install wizard via
http://dockerhost:port
- Add config.php settings:
'htaccess.RewriteBase' => '/',
'overwritewebroot' => 'cloud',
- Update .htaccess:
./occ maintenance:update:htaccess
- Attempt connection:
http://dockerhost:port/cloud
Bundled apache2 config has not been adjusted in any way.
Apache2 config
# cat /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
apache2 access.log (repeating):
[11/Nov/2019:17:57:04 +0200] "GET /cloud/login HTTP/1.0" 302 921 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0"
EDIT: I’ve simplified the problem down a bit, by taking out the nginx reverse proxy from image, leaving overwritewebroot
and htaccess.RewriteBase
as the only changed settings.
Full description contains details of my entire setup, but it is largely irrelevant. Exact same redirect loop occurs without it.
Full description
nginx version: nginx/1.12.2
Nginx reverse proxy configuration:
nginx reverse proxy config - Pastebin.com
The output of config.php file in /var/www/html/config
:
<?php
$CONFIG = array (
'instanceid' => 'redacted',
'passwordsalt' => 'redacted',
'secret' => 'redacted',
'trusted_domains' =>
array (
0 => 'dockerhost:port',
1 => 'reverse.proxy.address',
2 => 'public.domain.address',
),
'trusted_proxies' =>
array (
0 => 'reverse.proxy.ip',
),
'htaccess.RewriteBase' => '/',
'overwritehost' => 'reverse.proxy.address',
'overwriteprotocol' => 'https',
'overwritewebroot' => 'cloud',
'overwrite.cli.url' => 'https://reverse.proxy.address/cloud',
'datadirectory' => '/var/www/html/data',
'dbtype' => 'mysql',
'version' => '17.0.1.0',
'dbname' => 'redacted',
'dbhost' => 'redacted',
'dbport' => 'redacted',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'redacted',
'dbpassword' => 'redacted',
'installed' => true,
'maintenance' => false,
'ldapIgnoreNamingRules' => false,
'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
'theme' => '',
'loglevel' => 2,
);
The output of your Apache/nginx/system log in /var/log/____
:
nginx access.log (repeating):
[11/Nov/2019:17:57:04 +0200] "GET /cloud/login HTTP/2.0" 302 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0"