Restore start.sh from 0.5.5
This commit is contained in:
81
start.sh
81
start.sh
@@ -121,67 +121,6 @@ normalize_host() {
|
||||
esac
|
||||
}
|
||||
|
||||
common_domain_suffix_two() {
|
||||
local host_a="$1"
|
||||
local host_b="$2"
|
||||
local IFS='.'
|
||||
local -a parts_a=()
|
||||
local -a parts_b=()
|
||||
read -ra parts_a <<< "$host_a"
|
||||
read -ra parts_b <<< "$host_b"
|
||||
local i=$(( ${#parts_a[@]} - 1 ))
|
||||
local j=$(( ${#parts_b[@]} - 1 ))
|
||||
local suffix=""
|
||||
|
||||
while [ $i -ge 0 ] && [ $j -ge 0 ]; do
|
||||
if [ "${parts_a[$i]}" = "${parts_b[$j]}" ]; then
|
||||
if [ -z "$suffix" ]; then
|
||||
suffix="${parts_a[$i]}"
|
||||
else
|
||||
suffix="${parts_a[$i]}.$suffix"
|
||||
fi
|
||||
((i--))
|
||||
((j--))
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
printf '%s\n' "$suffix"
|
||||
}
|
||||
|
||||
common_domain_suffix() {
|
||||
if [ "$#" -eq 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
local suffix="$1"
|
||||
shift
|
||||
|
||||
while [ "$#" -gt 0 ] && [ -n "$suffix" ]; do
|
||||
suffix="$(common_domain_suffix_two "$suffix" "$1")"
|
||||
shift
|
||||
done
|
||||
|
||||
printf '%s\n' "$suffix"
|
||||
}
|
||||
|
||||
derive_default_rp_id() {
|
||||
local hosts=("$PHOTOS_HOST")
|
||||
if [ "$USE_SUBDOMAIN_ROUTING" = true ]; then
|
||||
hosts+=("$ACCOUNTS_HOST" "$AUTH_HOST" "$CAST_HOST" "$ALBUMS_HOST" "$FAMILY_HOST")
|
||||
fi
|
||||
|
||||
local suffix
|
||||
suffix="$(common_domain_suffix "${hosts[@]}")"
|
||||
|
||||
if [ -n "$suffix" ]; then
|
||||
printf '%s\n' "$suffix"
|
||||
else
|
||||
printf '%s\n' "$PHOTOS_HOST"
|
||||
fi
|
||||
}
|
||||
|
||||
ACCOUNTS_HOST="$(normalize_host "$ACCOUNTS_HOST")"
|
||||
AUTH_HOST="$(normalize_host "$AUTH_HOST")"
|
||||
CAST_HOST="$(normalize_host "$CAST_HOST")"
|
||||
@@ -216,11 +155,7 @@ else
|
||||
API_BASE="$BASE_URL"
|
||||
fi
|
||||
API_ORIGIN="${API_BASE}/api"
|
||||
if [ -n "${WEBAUTHN_RP_ID:-}" ]; then
|
||||
RP_ID="$WEBAUTHN_RP_ID"
|
||||
else
|
||||
RP_ID="$(derive_default_rp_id)"
|
||||
fi
|
||||
RP_ID="$PHOTOS_HOST"
|
||||
|
||||
log INFO "Application base URL: $BASE_URL"
|
||||
log INFO "Relying party ID: $RP_ID"
|
||||
@@ -1054,8 +989,7 @@ cat > "$CADDY_CONFIG" <<EOF_CADDY
|
||||
respond 204
|
||||
}
|
||||
|
||||
@api_host host ${PHOTOS_HOST}
|
||||
handle_path @api_host /api/* {
|
||||
handle_path /api/* {
|
||||
@api_cors_subdomain header Origin *
|
||||
header @api_cors_subdomain {
|
||||
Access-Control-Allow-Origin {http.request.header.Origin}
|
||||
@@ -1108,7 +1042,6 @@ cat > "$CADDY_CONFIG" <<EOF_CADDY
|
||||
}
|
||||
|
||||
@museum_api_get {
|
||||
host ${PHOTOS_HOST}
|
||||
method GET HEAD
|
||||
path_regexp museum_api_get ^/(admin|authenticator|billing|cast|collections|custom-domain|diff|discount|email-hash|emails-from-hashes|emergency-contacts|family|file|file-link|files|fire|info|job|mail|metrics|multipart-upload-urls|offers|options|pass-info|passkeys|public-collection|push|queue|remote-store|storage-bonus|thumbnail|trash|unknown-api|upload-urls|user|user-entity|verify-password)(/|$)
|
||||
}
|
||||
@@ -1122,7 +1055,6 @@ cat > "$CADDY_CONFIG" <<EOF_CADDY
|
||||
}
|
||||
|
||||
@write_methods {
|
||||
host ${PHOTOS_HOST}
|
||||
not method GET
|
||||
not method HEAD
|
||||
}
|
||||
@@ -1218,11 +1150,7 @@ cat > "$CADDY_CONFIG" <<EOF_CADDY
|
||||
respond 204
|
||||
}
|
||||
|
||||
@api_photos {
|
||||
host ${PHOTOS_HOST}
|
||||
path /api/*
|
||||
}
|
||||
handle @api_photos {
|
||||
handle_path /api/* {
|
||||
@api_cors_path header Origin *
|
||||
header @api_cors_path {
|
||||
Access-Control-Allow-Origin {http.request.header.Origin}
|
||||
@@ -1239,7 +1167,6 @@ cat > "$CADDY_CONFIG" <<EOF_CADDY
|
||||
header_up X-Forwarded-For {http.request.header.X-Forwarded-For}
|
||||
header_up X-Forwarded-Proto {http.request.header.X-Forwarded-Proto}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handle /health {
|
||||
@@ -1276,7 +1203,6 @@ cat > "$CADDY_CONFIG" <<EOF_CADDY
|
||||
}
|
||||
|
||||
@museum_api_get_path {
|
||||
host ${PHOTOS_HOST}
|
||||
method GET HEAD
|
||||
path_regexp museum_api_get_path ^/(admin|authenticator|billing|cast|collections|custom-domain|diff|discount|email-hash|emails-from-hashes|emergency-contacts|family|file|file-link|files|fire|info|job|mail|metrics|multipart-upload-urls|offers|options|pass-info|passkeys|public-collection|push|queue|remote-store|storage-bonus|thumbnail|trash|unknown-api|upload-urls|user|user-entity|verify-password)(/|$)
|
||||
}
|
||||
@@ -1290,7 +1216,6 @@ cat > "$CADDY_CONFIG" <<EOF_CADDY
|
||||
}
|
||||
|
||||
@write_methods_path {
|
||||
host ${PHOTOS_HOST}
|
||||
not method GET
|
||||
not method HEAD
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user