Skip to content

Redirecting bug since 15.0.2 #13713

Closed

Description

@mrzapp

Whenever a redirect happens, like from the /apps/ to the /apps/files/ path, NextCloud now redirects using the server provided hostname and port instead of the one requested by the client.

For instance, if running via Docker on localhost:8000 and using a proxy pass with cloud.example.com, the address cloud.example.com/apps/ will redirect to localhost:8000/apps/files/.

This happens with the / to /login redirect as well, so this bug completely prevents access to the instance from the web interface, unless you manually correct the URL afterwards.

Also discussed here: https://help.nextcloud.com/t/nextcloud-15-redirect-to-local-ip/45352

Activity

  1. mrzapp commented on Jan 21, 2019

    @mrzapp
    Author

    Related to #13710

  2. RandomMetalhead commented on Jan 21, 2019

    @RandomMetalhead

    Same problem and same setup:
    Apache Proxy -> Docker -> Nexcloud and always redirecting to https://127.0.0.1:8080/login. With 15.0 it worked fine, update to 15.0.2 broke

  3. kesselb commented on Jan 21, 2019

    @kesselb
    Contributor
  4. RandomMetalhead commented on Jan 21, 2019

    @RandomMetalhead

    Provided links did not help.
    What helped is changing:
    'overwrite.cli.url' => 'https://XXXX.de',
    to
    'overwritehost' => 'XXXX.de', 'overwriteprotocol' => 'https',

    It seems for me 'overwrite.cli.url' in config.php is broken

  5. mrzapp commented on Jan 21, 2019

    @mrzapp
    Author

    Yep, @RandomMetalhead's solution works

  6. kesselb commented on Jan 21, 2019

    @kesselb
    Contributor

    Great 🎉

    image

    Provided links did not help.

    I guess we could improve the documentation here. It's not obvious that the bold text are configuration parameters.

    @RandomMetalhead you also need overwrite.cli.url (https://github.com/nextcloud/server/blob/stable15/config/config.sample.php#L477-L485)

  7. RandomMetalhead commented on Jan 21, 2019

    @RandomMetalhead

    The main issue was, that in 15.0.0 only having 'overwrite.cli.url' and 'overwriteprotocol' was sufficient for Nextcloud. It seems, that for 15.0.2 'overwritehost' is necessary. At least in docker version with Apache-Proxy. I have readded 'overwrite.cli.url', too. So my config looks like this now and is working perfectly:

    'overwritehost' => 'XXX.de', 'overwriteprotocol' => 'https', 'overwrite.cli.url' => 'https://XXX.de',

  8. kesselb commented on Jan 21, 2019

    @kesselb
    Contributor

    The main issue was, that in 15.0.0 only having 'overwrite.cli.url' and 'overwriteprotocol' was sufficient for Nextcloud. It seems, that for 15.0.2 'overwritehost' is necessary.

    Thank you for pointing this out 👍

    @MorrisJobke @rullzer @J0WI they were many reports within the last days about this. I suppose this is related to #13116 because the docker network is not trusted by default. In this case HTTP_FORWARDED_HOST is not longer trusted. What do you suggest? Is it possible to add this for the official docker image? 🏓

  9. kesselb commented on Jan 21, 2019

    @kesselb
    Contributor

    CIDR is possible for trusted_network since nextcloud 15. Something like 172.0.0.0/8 as trusted proxy would work (not sure if docker uses 172.x all the time).

    @kyrofa @enoch85 (not sure if snap or vm is running into the same. just in case)

  10. enoch85 commented on Jan 21, 2019

    @enoch85
    Member

    Thanks for the heads up @danielkesselberg Nothing reported, and nothing I've experienced myself.

  11. J0WI commented on Jan 21, 2019

    @J0WI
    Contributor
  12. kesselb commented on Jan 22, 2019

    @kesselb
    Contributor

    nextcloud/docker#527 makes it easier to configure these parameters 👍

    • Nextcloud 15.0.0: Nextcloud accept HTTP_FORWARDED_HOST from Nginx (or any other proxy).
    • Nextcloud 15.0.2: Nextcloud does not accept HTTP_FORWARDED_HOST from Nginx (or any other proxy).

    In #13116 we did some security hardening (trust HTTP_FORWARDED_HOST only if proxy is trusted proxy). Nextcloud behind nginx worked well for most people without setting overwritehost. @J0WI do you think we could set trusted_network to 172.0.0.0/8 by default (and make it configurable) for the docker image?

  13. J0WI commented on Jan 22, 2019

    @J0WI
    Contributor

    172.0.0.0/8 would be a bad idea, only 172.16.0.0/12 is private. If we trust them by default, we should probably trust all RFC 1918 (and RFC 4193?) networks?
    However, you can use any other IP for Docker, so I think we need nextcloud/docker#527 anyway.

  14. neeral85 commented on Jan 23, 2019

    @neeral85

    I'm running https://www.hanssonit.se/nextcloud-vm/

    my ip is 172.18.1.10 and
    'overwritehost' => 'XXX.de', 'overwriteprotocol' => 'https', 'overwrite.cli.url' => 'https://XXX.de',
    was not working for me.

  15. enoch85 commented on Jan 23, 2019

    @enoch85
    Member

    @neeral85 So you have issues on the Nextcloud VM as described in this issue?

  16. 9 remaining items

  17. kesselb commented on Apr 2, 2019

    @kesselb
    Contributor

    If you run nextcloud behind a reverse proxy usually some headers (like X-Forwarded-For) are present. You should see a setup warning (nextcloud 16) for such cases: #14261

  18. kesselb commented on Apr 2, 2019

    @kesselb
    Contributor

    To be done: A warning if some required parameters not present (e.g. apache2 does not forward x-forwarded-proto while nginx and traefik does => overwriteproto is required for apache2).

  19. MorrisJobke commented on May 7, 2019

    @MorrisJobke
    Member

    Fix is in #15430

  20. added and removed
    0. Needs triagePending check for reproducibility or if it fits our roadmap
    on May 7, 2019
  21. Darkless012 commented on Jan 29, 2024

    @Darkless012

    The main issue was, that in 15.0.0 only having 'overwrite.cli.url' and 'overwriteprotocol' was sufficient for Nextcloud. It seems, that for 15.0.2 'overwritehost' is necessary. At least in docker version with Apache-Proxy. I have readded 'overwrite.cli.url', too. So my config looks like this now and is working perfectly:

    'overwritehost' => 'XXX.de', 'overwriteprotocol' => 'https', 'overwrite.cli.url' => 'https://XXX.de',

    I'm running Nextcloud 25 and the login issue redirect was appearing.
    Fixed by adding overwritehost and overwriteprotocol into config.php

    Shame that config is JSON, because you can't use simple Ansible to manage line in file.

  22. a214218 commented on Oct 24, 2024

    @a214218

    hi. I'm just starting to learn Linux. I have NextCloud 30.0.1 set up at home on Debian 12.7. I am also being redirected to a local IP... I use DDNS on the router for access.
    made the following changes:
    'overwritehost' => 'XXX.link', 'overwriteprotocol' => 'https', 'overwrite.cli.url' => 'https://XXX.link ',
    the error persists (((

    masters - I ask for help

    p.s. I checked with a static ip address on the router. with forwarding to NextCloud. Error.... redirects to the local IP (((((

  23. elclanrs commented on Dec 13, 2024

    @elclanrs

    Experiencing the same issue with version 30. Tried setting the overwrites as mentioned above but no luck. This makes it impossible to login in Android because when you try to grant access to the device it goes to 127.0.0.1:8080/login/flow which produces an ERR_CONNECTION_REFUSED error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions