Files
solace-bg-dubai/deployment/proxmox/deploy-nginx.sh
T
2026-07-07 09:41:38 -07:00

44 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Install Nginx reverse proxy on the Solace frontend CT (VMID 3000).
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_FILE="$SCRIPT_DIR/config/dapp.conf"
[[ -f "$CONFIG_FILE" ]] && source "$CONFIG_FILE"
VMID="${VMID_FRONTEND:-3000}"
NGINX_TEMPLATE="$SCRIPT_DIR/templates/nginx.conf"
LOCATIONS_TEMPLATE="$SCRIPT_DIR/templates/solace-treasury-locations.conf"
if ! command -v pct &>/dev/null; then
echo "ERROR: pct not found — run on Proxmox host" >&2
exit 1
fi
echo "Installing Nginx on CT $VMID..."
pct exec "$VMID" -- bash -c '
set -euo pipefail
apt-get update -qq
apt-get install -y nginx
systemctl enable nginx
'
pct push "$VMID" "$NGINX_TEMPLATE" /etc/nginx/sites-available/solace-treasury
pct push "$VMID" "$LOCATIONS_TEMPLATE" /etc/nginx/snippets/solace-treasury-locations.conf
pct exec "$VMID" -- bash -c '
mkdir -p /etc/nginx/snippets
ln -sf /etc/nginx/sites-available/solace-treasury /etc/nginx/sites-enabled/solace-treasury
rm -f /etc/nginx/sites-enabled/default
mkdir -p /etc/nginx/ssl
if [[ ! -f /etc/nginx/ssl/cert.pem ]]; then
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/nginx/ssl/key.pem -out /etc/nginx/ssl/cert.pem \
-subj "/CN=solace-treasury.local"
fi
nginx -t
systemctl restart nginx
'
echo "Nginx deployed on CT $VMID (self-signed SSL in /etc/nginx/ssl/)"