Skip to content

Commit

Permalink
Merge pull request #158 from thelittlefireman/patch-6
Browse files Browse the repository at this point in the history
Fix redirect issue when docker is behind an other reverse proxy
  • Loading branch information
crazy-max authored Nov 7, 2024
2 parents 2630763 + 5ab6c89 commit 83c75a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 7 additions & 1 deletion rootfs/etc/cont-init.d/03-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ APC_SHM_SIZE=${APC_SHM_SIZE:-128M}
REAL_IP_FROM=${REAL_IP_FROM:-0.0.0.0/32}
REAL_IP_HEADER=${REAL_IP_HEADER:-X-Forwarded-For}
LOG_IP_VAR=${LOG_IP_VAR:-remote_addr}
if [ -z "$SUBDIR" ]
then
REDIRECT_URL='$scheme://$host'
else
REDIRECT_URL=$SUBDIR
fi

HSTS_HEADER=${HSTS_HEADER:-max-age=15768000; includeSubDomains}
XFRAME_OPTS_HEADER=${XFRAME_OPTS_HEADER:-SAMEORIGIN}
Expand Down Expand Up @@ -87,7 +93,7 @@ sed -e "s/@UPLOAD_MAX_SIZE@/$UPLOAD_MAX_SIZE/g" \
-e "s/@HSTS_HEADER@/$HSTS_HEADER/g" \
-e "s/@XFRAME_OPTS_HEADER@/$XFRAME_OPTS_HEADER/g" \
-e "s/@RP_HEADER@/$RP_HEADER/g" \
-e "s#@SUBDIR@#$SUBDIR#g" \
-e "s#@REDIRECT_URL@#$REDIRECT_URL#g" \
/tpls/etc/nginx/nginx.conf >/etc/nginx/nginx.conf

if [ "$LISTEN_IPV6" != "true" ]; then
Expand Down
10 changes: 5 additions & 5 deletions rootfs/tpls/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ http {
# Handle Microsoft DAV clients
location = / {
if ( $http_user_agent ~ ^DavClnt ) {
return 302 @SUBDIR@/remote.php/webdav/$is_args$args;
return 302 @REDIRECT_URL@/remote.php/webdav/$is_args$args;
}
}

Expand All @@ -141,18 +141,18 @@ http {

location ^~ /.well-known {
location = /.well-known/carddav {
return 301 @SUBDIR@/remote.php/dav/;
return 301 @REDIRECT_URL@/remote.php/dav/;
}
location = /.well-known/caldav {
return 301 @SUBDIR@/remote.php/dav/;
return 301 @REDIRECT_URL@/remote.php/dav/;
}
location /.well-known/acme-challenge {
try_files $uri $uri/ =404;
}
location /.well-known/pki-validation {
try_files $uri $uri/ =404;
}
return 301 @SUBDIR@/index.php$request_uri;
return 301 @REDIRECT_URL@/index.php$request_uri;
}

location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) {
Expand Down Expand Up @@ -223,7 +223,7 @@ http {

# Rule borrowed from `.htaccess`
location /remote {
return 301 @SUBDIR@/remote.php$request_uri;
return 301 @REDIRECT_URL@/remote.php$request_uri;
}

location / {
Expand Down

0 comments on commit 83c75a6

Please sign in to comment.