fix trusted_proxies for caddy in case of a reverse proxy situation

Signed-off-by: szaimen <szaimen@e.mail.de>
This commit is contained in:
szaimen 2022-06-15 12:42:14 +02:00
parent 145d83c000
commit f0ddf95a3e
3 changed files with 36 additions and 8 deletions

View file

@ -21,17 +21,30 @@ if [ -z "$APACHE_PORT" ]; then
export APACHE_PORT="443"
fi
# Change the Caddyfile
# Change variables in case of reverse proxies
if [ "$APACHE_PORT" != '443' ]; then
export PROTOCOL="http"
export NC_DOMAIN=""
CADDYFILE="$(sed 's|auto_https.*|auto_https off|' /Caddyfile)"
else
export PROTOCOL="https"
fi
# Change the auto_https in case of reverse proxies
if [ "$APACHE_PORT" != '443' ]; then
CADDYFILE="$(sed 's|auto_https.*|auto_https off|' /Caddyfile)"
else
CADDYFILE="$(sed 's|auto_https.*|auto_https disable_redirects|' /Caddyfile)"
fi
echo "$CADDYFILE" > /Caddyfile
# Change the trusted_proxies in case of reverse proxies
if [ "$APACHE_PORT" != '443' ]; then
CADDYFILE="$(sed 's|# trusted_proxies placeholder|trusted_proxies private_ranges|' /Caddyfile)"
else
CADDYFILE="$(sed 's|trusted_proxies private_ranges|# trusted_proxies placeholder|' /Caddyfile)"
fi
echo "$CADDYFILE" > /Caddyfile
# Add caddy path
mkdir -p /mnt/data/caddy/