Skip to content

overwritewebroot in config.php causes too many redirects behind nginx reverse proxy #20338

@DoctorDrunk

Description

@DoctorDrunk

Steps to reproduce

  1. podman run -d --rm --name nextcloud --network nginx-network nextcloud
  2. 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,
    ),
  ),
  'instanceid' => 'oc8q4k57uxw8',
  'passwordsalt' => 'yx1I5LCWvw+MZK2HtpEeA2XF0pgubt',
  'secret' => 'SQmZu2GRO5EQBOn3arKBT3vuND/XoW4mhN2Dtzd+2kwLkVGl',
  'trusted_domains' =>
  array (
    0 => '192.168.2.81',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'sqlite3',
  'version' => '18.0.3.0',
  'overwrite.cli.url' => 'http://192.168.2.81:8080',
  'installed' => true,
  'trusted_proxies' =>
  array (
    0 => '10.0.0.0/8',
    1 => '172.16.0.0/12',
    2 => '192.168.0.0/16',
  ),
  'overwritewebroot' => '/nextcloud',
);
  1. podman run -d --name nginx -v nginx-conf.d:/etc/nginx/conf.d/ -v nginx-certs:/etc/nginx/certs/ --network nginx-network -p 80:80 -p 443:443 nginx
  2. default.conf
server {
    listen 80 default_server;

    server_name _;
    return 301 https://$host$request_uri;
}

server {
    listen       443 ssl;
    server_name  192.168.2.81;

    ssl_certificate     certs/192.168.2.81.crt;
    ssl_certificate_key certs/192.168.2.81.key;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    location /nextcloud {
        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Host  $host:$server_port;
        proxy_set_header X-Real-IP         $remote_addr;
        proxy_pass                         http://nextcloud:80;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

Expected behaviour

Redirect to nextcloud login under https://192.168.2.81/nextcloud/login

Actual behaviour

Infinite HTTP 302 Found loop with Location https://192.168.2.81/nextcloud/login`

Changing location /nextcloud { to location / { in default.conf and removing overwritewebroot in config.php results in a working nextcloud instance under https://192.168.2.81.

Server configuration

Operating system: Fedora 31 Server with podman

Web server: nginx 1.17.9 reverse proxy, docker.io/library/nextcloud latest 13712f835d9a

Database: SQLite

PHP version: docker.io/library/nextcloud latest 13712f835d9a

Nextcloud version: (see Nextcloud admin page) docker.io/library/nextcloud latest 13712f835d9a

Updated from an older Nextcloud/ownCloud or fresh install: fresh install

Where did you install Nextcloud from: container image docker.io/library/nextcloud latest 13712f835d9a

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagePending check for reproducibility or if it fits our roadmapbug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions