@@ -4,6 +4,16 @@ upstream php-handler {
44 server 127.0.0.1 :9000;
55}
66
7+ map $http_x_forwarded_proto $real_scheme {
8+ default $scheme ;
9+ https https;
10+ }
11+
12+ map $http_x_forwarded_port $real_port {
13+ default $server_port ;
14+ 443 443;
15+ }
16+
717# Set the ` immutable` cache control options only for assets with a cache busting ` v` argument
818map $arg_v $asset_immutable {
919 " " " " ;
@@ -87,7 +97,7 @@ server {
8797 # Rule borrowed from ` .htaccess` to handle Microsoft DAV clients
8898 location = / {
8999 if ( $http_user_agent ~ ^DavClnt ) {
90- return 302 /remote.php /webdav/$is_args$args ;
100+ return 302 $real_scheme :// $host : $real_port /remote.php /webdav/$is_args$args ;
91101 }
92102 }
93103
@@ -104,12 +114,12 @@ server {
104114 location ^~ /.well -known {
105115 # The following 6 rules are borrowed from ` .htaccess`
106116
107- location = /.well -known/carddav { return 301 /remote.php /dav/; }
108- location = /.well -known/caldav { return 301 /remote.php /dav/; }
117+ location = /.well -known/carddav { return 301 $real_scheme :// $host : $real_port /remote.php /dav/; }
118+ location = /.well -known/caldav { return 301 $real_scheme :// $host : $real_port /remote.php /dav/; }
109119
110120 # Let Nextcloud's API for ` /.well-known` URIs handle all other
111121 # requests by passing them to the front-end controller.
112- return 301 /index .php $request_uri ;
122+ return 301 $real_scheme :// $host : $real_port /index .php $request_uri ;
113123 }
114124
115125 # Rules borrowed from ` .htaccess` to hide certain paths from clients
@@ -158,7 +168,7 @@ server {
158168
159169 # Rule borrowed from ` .htaccess`
160170 location /remote {
161- return 301 /remote.php $request_uri ;
171+ return 301 $real_scheme :// $host : $real_port /remote.php $request_uri ;
162172 }
163173
164174 location / {
0 commit comments