Skip to content

Commit

Permalink
feature: do not use port on tiles URL
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonStuff committed Nov 11, 2024
1 parent 5cbccd8 commit 0f155d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 1 addition & 3 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
# to use handle_path for prefixes, pmtiles_proxy must have a defined
# position in the ordering of handlers.
order pmtiles_proxy before reverse_proxy
email ${MAPS_EMAIL}
}
Expand All @@ -17,7 +15,7 @@
}
}

${MAPS_DOMAIN} {
${MAPS_DOMAIN}:${MAPS_PORT} {
@allowed_origins {
expression {header.Origin}.matches('^https://([a-zA-Z0-9-]+\\.)*${MAPS_SERVE_DOMAIN}$') || {header.Origin}.matches('^https://maplibre\\.org$')
}
Expand Down
14 changes: 12 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
#!/bin/sh
set -e

# Debug: print environment variables
# Extract port from MAPS_DOMAIN if it exists
DOMAIN_WITHOUT_PORT=$(echo "${MAPS_DOMAIN}" | cut -d: -f1)
PORT=$(echo "${MAPS_DOMAIN}" | grep -o ':[0-9]\+' | cut -d: -f2)
PORT=${PORT:-443} # Default to 443 if no port specified

# Export cleaned domain and port
export MAPS_DOMAIN=$DOMAIN_WITHOUT_PORT
export MAPS_PORT=$PORT

echo "Environment variables:"
echo "MAPS_DOMAIN=${MAPS_DOMAIN}"
echo "MAPS_PORT=${MAPS_PORT}"
echo "MAPS_PMTILES_LOCATION=${MAPS_PMTILES_LOCATION}"
echo "MAPS_EMAIL=${MAPS_EMAIL}"
echo "MAPS_SERVE_DOMAIN=${MAPS_SERVE_DOMAIN}"
Expand All @@ -13,7 +22,8 @@ export MAPS_DOMAIN
export MAPS_PMTILES_LOCATION
export MAPS_EMAIL
export MAPS_SERVE_DOMAIN
envsubst '${MAPS_DOMAIN} ${MAPS_PMTILES_LOCATION} ${MAPS_EMAIL} ${MAPS_SERVE_DOMAIN}' < /etc/caddy/Caddyfile.template > /etc/caddy/Caddyfile
export MAPS_PORT
envsubst '${MAPS_DOMAIN} ${MAPS_PORT} ${MAPS_PMTILES_LOCATION} ${MAPS_EMAIL} ${MAPS_SERVE_DOMAIN}' < /etc/caddy/Caddyfile.template > /etc/caddy/Caddyfile

echo "Caddyfile:"
cat /etc/caddy/Caddyfile
Expand Down

0 comments on commit 0f155d0

Please sign in to comment.