Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
DoctorDrunk opened this issue Apr 6, 2020 · 8 comments
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug

Comments

@DoctorDrunk
Copy link

DoctorDrunk commented Apr 6, 2020

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

@DoctorDrunk DoctorDrunk added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Apr 6, 2020
@DoctorDrunk
Copy link
Author

I played around with htaccess.RewriteBase, overwritehost, overwrite.cli.url, ...

No success.

@DoctorDrunk
Copy link
Author

careful bump

@pniclan
Copy link

pniclan commented May 12, 2020

Just install nextcloud vanilla plugin from freenas. Nextcloud can be accessed by IP or server name (nc2) and is working as design.

Adding the 'overwritewebroot' => '/nextcloud' in the config.php, and got the too many redirects.

Here are the outputs of curl -sILk nc2/nextcloud | egrep 'HTTP|Loc' | sed 's/Loc/ -> Loc/g' for both without and with the overwritewebroot

Without the overwritewebroot :
[user@anotherserver]$ curl -sILk nc2 | egrep 'HTTP|Loc' | sed 's/Loc/ -> Loc/g'
HTTP/1.1 302 Found
-> Location: http://nc2/login
HTTP/1.1 200 OK
[user@anotherserver]$

Without the overwritewebroot :
[user@anotherserver]$ curl -sILk nc2/nextcloud | egrep 'HTTP|Loc' | sed 's/Loc/ -> Loc/g'
HTTP/1.1 302 Found
-> Location: /nextcloud/
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
HTTP/1.1 302 Found
-> Location: http://nc2/nextcloud/login
[user@anotherserver]$

@NazarILdarovich
Copy link

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.

thanks , in my case adding the "location /nextcloud" instead of "location /" in 443 section of proxy config solved the issue

@rqi14
Copy link

rqi14 commented Feb 9, 2021

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.

thanks , in my case adding the "location /nextcloud" instead of "location /" in 443 section of proxy config solved the issue

Hello. Do you mind sharing which line in which proxy config file you edited?

@SigiSang
Copy link

SigiSang commented Apr 28, 2021

I had this exact issue and have it fixed. In my opinion this proves it is not an issue/bug with nextcloud but faulty config in the reverse proxy (although I found it hard to find proper documentation for this).
See here nextcloud/docker#401 (comment)

@szaimen
Copy link
Contributor

szaimen commented Jul 2, 2021

Thank you for taking the time to report a bug! 👍

As this seems to be a setup issue I would like to ask you to raise your question in the forums: https://help.nextcloud.com
If you wish support with setup issues from Nextcloud GmbH we offer this as part of the Nextcloud subscription. Learn more about this at https://nextcloud.com/enterprise/

@szaimen szaimen closed this as completed Jul 2, 2021
@Gamechiefx
Copy link

nextcloud 25 and still not fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug
Projects
None yet
Development

No branches or pull requests

7 participants