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

Fix redirect issue when docker is behind an other reverse proxy #158

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -38,6 +38,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 @@ -83,7 +89,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 @@ -125,7 +125,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 @@ -137,18 +137,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 @@ -219,7 +219,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