fix: replacement conditions#
This commit is contained in:
1 parent
e005bd330e
commit
259dcab1b5
1 file changed
+24
-14
+24
-14
@@ -1,31 +1,41 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Ensure SERVER_NAME is set
|
||||||
|
if [ -z "$SERVER_NAME" ]; then
|
||||||
|
echo "[entrypoint] SERVER_NAME is not set. Using default value: localhost"
|
||||||
|
SERVER_NAME="localhost"
|
||||||
|
else
|
||||||
|
echo "[entrypoint] Using SERVER_NAME=$SERVER_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
# Render vhost ONLY into http.d so it's inside http{} context
|
# Render vhost ONLY into http.d so it's inside http{} context
|
||||||
if [ -f /etc/nginx/templates/default.conf.template ]; then
|
if [ -f /etc/nginx/templates/default.conf.template ]; then
|
||||||
if [ "$ENABLE_BASIC_AUTH" = "true" ]; then
|
|
||||||
echo "[entrypoint] Enabling basic authentication..."
|
|
||||||
if [ -f /etc/nginx/htpasswd ]; then
|
|
||||||
envsubst '$SERVER_NAME' < /etc/nginx/templates/default.conf.template | \
|
|
||||||
sed '/location \/ {/a \\t\tauth_basic "Restricted Content";\n\t\tauth_basic_user_file /etc/nginx/htpasswd;' \
|
|
||||||
> /etc/nginx/http.d/default.conf
|
|
||||||
else
|
|
||||||
echo "[entrypoint] ERROR: htpasswd file not found at /etc/nginx/htpasswd" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "[entrypoint] Basic authentication is disabled."
|
|
||||||
envsubst '$SERVER_NAME' < /etc/nginx/templates/default.conf.template > /etc/nginx/http.d/default.conf
|
envsubst '$SERVER_NAME' < /etc/nginx/templates/default.conf.template > /etc/nginx/http.d/default.conf
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "[entrypoint] ERROR: missing /etc/nginx/templates/default.conf.template" >&2
|
echo "[entrypoint] ERROR: missing /etc/nginx/templates/default.conf.template" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[entrypoint] Using SERVER_NAME=$SERVER_NAME"
|
# Add basic authentication if enabled
|
||||||
|
if [ "$ENABLE_BASIC_AUTH" = "true" ]; then
|
||||||
|
echo "[entrypoint] Enabling basic authentication..."
|
||||||
|
if [ -f /etc/nginx/htpasswd ]; then
|
||||||
|
sed -i '/location \/ {/a \\t\tauth_basic "Restricted Content";\n\t\tauth_basic_user_file /etc/nginx/htpasswd;' /etc/nginx/http.d/default.conf
|
||||||
|
else
|
||||||
|
echo "[entrypoint] ERROR: htpasswd file not found at /etc/nginx/htpasswd" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "[entrypoint] Basic authentication is disabled."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test nginx configuration
|
||||||
nginx -t || { echo "[entrypoint] nginx config test failed" >&2; cat /var/log/nginx/error.log || true; exit 1; }
|
nginx -t || { echo "[entrypoint] nginx config test failed" >&2; cat /var/log/nginx/error.log || true; exit 1; }
|
||||||
|
|
||||||
|
# Clear Laravel caches
|
||||||
php artisan config:clear
|
php artisan config:clear
|
||||||
php artisan cache:clear
|
php artisan cache:clear
|
||||||
|
|
||||||
|
# Start supervisord
|
||||||
exec /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
|
exec /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
|
||||||
Reference in new issue
Block a user