Skip to content

Nginx should respect the X-Forwarded-Proto header. #825

@mreiche

Description

@mreiche

Description of the change

When Nginx respects the headers X-Forwarded-Proto and X-Forwarded-Port, most setups would work out of the box because the headers are already present (like Traefik does).

The original issue came from failing auto-discovery, because Nginx redirects to insecure http scheme adresses MacOSX' accountsd won't follow.

The solution provided by the documentation https://github.com/nextcloud/helm/tree/main/charts/nextcloud#service-discovery-with-nginx-and-ingress is only for Nginx ingress and could be skipped with this change.

It's possible to improve the nginx configuration by respecting the X-Forwarded-Proto header:

map $http_x_forwarded_proto $real_scheme {
	default https;
	https https;
}

location = /.well-known/carddav     { return 301 $real_scheme://$host/remote.php/dav/; }
location = /.well-known/caldav      { return 301 $real_scheme://$host/remote.php/dav/; }

Benefits

  • All URLs are directly redirected to the correct public scheme (from Ingress).
  • Easier out-of-the-box setup

Possible drawbacks

  • The configuration needs to add $real_scheme for every redirect.
  • Maybe we need to integrate X-Forwarded-Port as well for instances running different from 443

Additional information

(none)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions