Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
INFRA-61 – fix SSL proxy redirect loop
Browse files Browse the repository at this point in the history
  • Loading branch information
NoelLH committed May 28, 2022
1 parent 8881493 commit 378b6f4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions secrets_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,20 @@ fi
# Load the S3 secrets file contents into the environment variables
export $(aws s3 cp s3://${SECRETS_BUCKET_NAME}/secrets - | grep -v '^#' | xargs)

# Fix redirect loop behind ALB. https://forum.mautic.org/t/mautic-redirect-loop/16990/3
INDEX_FILE="/var/www/html/index.php"
NEW_LINE="\$_SERVER[\"HTTPS\"] = \"on\";\n"
if test -f "$INDEX_FILE"; then
if grep -q "$NEW_LINE" "$INDEX_FILE"; then
echo "SSL modification already in place"
else
# Existing line regex based on https://github.com/mautic/mautic/blob/4.x/index.php
sed -i -e 's/(<\?php)/$1\n\$_SERVER["HTTPS"] = "on";/g' "$INDEX_FILE"
echo "SSL modification applied"
fi
else
echo "No index.php – no SSL modification"
fi

# Call the normal Mautic entrypoint script then the e.g. start Apache CMD (argument to entrypoint).
/entrypoint.sh "$@"

0 comments on commit 378b6f4

Please sign in to comment.