fix: nginx headers at server block level; add Webuzo detection to deploy

deploy.sh:
- add step 3: nginx config apply with Webuzo/standard detection
- configurable via NGINX_CONF_SRC and NGINX_DOMAIN variables

setup-project.sh:
- move add_header to server block level (inside location / they are
  overridden by Webuzo's regex location and never sent)
- detect Webuzo nginx binary (/usr/local/apps/nginx/sbin/nginx)
  instead of hardcoded systemctl reload nginx

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
olekhondera
2026-02-21 01:21:39 +02:00
parent 425227c6b8
commit 99773cdbda
2 changed files with 37 additions and 10 deletions

View File

@@ -19,6 +19,8 @@ INSTALL_DIR="/opt/<project-name>"
SERVICE_USER="<project-user>"
SERVICE_NAME="<project-name>"
HEALTH_URL="http://localhost:3000/api/health"
NGINX_CONF_SRC="${INSTALL_DIR}/config/nginx/<project-name>.conf" # set to "" to skip
NGINX_DOMAIN="<your-domain>"
# -----------------------------------------
SOURCE_DIR="${1:-.}"
@@ -42,10 +44,26 @@ rsync -a --delete \
"${SOURCE_DIR}/" "${INSTALL_DIR}/"
chown -R "${SERVICE_USER}:${SERVICE_USER}" "${INSTALL_DIR}"
echo "[2/3] Installing dependencies..."
echo "[2/4] Installing dependencies..."
sudo -u "${SERVICE_USER}" HOME="${INSTALL_DIR}" bash -c "cd ${INSTALL_DIR} && npm ci --omit=dev"
echo "[3/3] Restarting service..."
echo "[3/4] Updating nginx config..."
if [[ -n "${NGINX_CONF_SRC:-}" && -f "${NGINX_CONF_SRC}" ]]; then
WEBUZO_DIR="/var/webuzo-data/nginx/custom/domains"
NGINX_BIN="/usr/local/apps/nginx/sbin/nginx"
if [[ -d "${WEBUZO_DIR}" ]]; then
cat "${NGINX_CONF_SRC}" > "${WEBUZO_DIR}/${NGINX_DOMAIN}.conf"
else
cp "${NGINX_CONF_SRC}" "/etc/nginx/conf.d/${SERVICE_NAME}.conf"
NGINX_BIN="nginx"
fi
"${NGINX_BIN}" -t && "${NGINX_BIN}" -s reload
echo "nginx reloaded"
else
echo "nginx: no config source set — skipping"
fi
echo "[4/4] Restarting service..."
systemctl daemon-reload
systemctl restart "${SERVICE_NAME}"
sleep 2
@@ -53,7 +71,7 @@ sleep 2
if systemctl is-active --quiet "${SERVICE_NAME}"; then
echo "Service running"
else
echo "Error: service failed to start"; exit 1
echo "Error: service failed to start — check: journalctl -u ${SERVICE_NAME} -n 50"; exit 1
fi
curl -sf "${HEALTH_URL}" || { echo "FAIL: health check"; exit 1; }