feat: add ability to inject a htpasswod file
This commit is contained in:
1 parent
afaf73e17a
commit
e005bd330e
5 files changed
+17
-113
No files matched your search
+16
-12
@@ -1,15 +1,22 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
SERVER_NAME="${SERVER_NAME:-$(hostname -f 2>/dev/null || hostname)}"
|
||||
export SERVER_NAME
|
||||
|
||||
# Ensure dirs
|
||||
mkdir -p /etc/nginx/http.d /etc/nginx/conf.d /run/nginx /run/php
|
||||
set -e
|
||||
|
||||
# Render vhost ONLY into http.d so it's inside http{} context
|
||||
if [ -f /etc/nginx/templates/default.conf.template ]; then
|
||||
envsubst '$SERVER_NAME' < /etc/nginx/templates/default.conf.template > /etc/nginx/http.d/default.conf
|
||||
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
|
||||
fi
|
||||
else
|
||||
echo "[entrypoint] ERROR: missing /etc/nginx/templates/default.conf.template" >&2
|
||||
exit 1
|
||||
@@ -21,7 +28,4 @@ nginx -t || { echo "[entrypoint] nginx config test failed" >&2; cat /var/log/ngi
|
||||
php artisan config:clear
|
||||
php artisan cache:clear
|
||||
|
||||
envsubst '$SERVER_NAME' < /etc/nginx/templates/default.conf.template > /etc/nginx/http.d/default.conf
|
||||
|
||||
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