dns proxy
Build and Push Docker Images / build-and-push (push) Failing after 52s

This commit is contained in:
2026-08-30 23:00:48 +02:00
parent 23a2d1964a
commit 07924fe892
3 changed files with 87 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
#!/bin/sh
set -eu
TARGET_URL="${TARGET_URL:-}"
LISTEN_PORT="${LISTEN_PORT:-8080}"
PROXY_INSECURE_TLS="${PROXY_INSECURE_TLS:-0}"
PRESERVE_HOST="${PRESERVE_HOST:-0}"
if [ -z "$TARGET_URL" ]; then
echo "TARGET_URL is required (e.g. https://internal.example.com)" >&2
exit 1
fi
case "$TARGET_URL" in
http://*|https://*) ;;
*)
echo "TARGET_URL must start with http:// or https://" >&2
exit 1
;;
esac
# Strip trailing slash so paths concatenate cleanly
TARGET_URL="${TARGET_URL%/}"
CADDYFILE="/etc/caddy/Caddyfile"
mkdir -p /etc/caddy
EXTRA_DIRECTIVES=""
if [ "$PRESERVE_HOST" = "1" ]; then
EXTRA_DIRECTIVES="${EXTRA_DIRECTIVES}
header_up Host {http.request.host}"
fi
if [ "$PROXY_INSECURE_TLS" = "1" ]; then
EXTRA_DIRECTIVES="${EXTRA_DIRECTIVES}
transport http {
tls_insecure_skip_verify
}"
fi
cat > "$CADDYFILE" <<EOF
{
admin off
auto_https off
}
:${LISTEN_PORT} {
reverse_proxy ${TARGET_URL} {${EXTRA_DIRECTIVES}
}
}
EOF
echo "Proxying :${LISTEN_PORT} -> ${TARGET_URL}"
if [ "$PROXY_INSECURE_TLS" = "1" ]; then
echo "TLS verification disabled for upstream"
fi
exec caddy run --config "$CADDYFILE" --adapter caddyfile