mailwolt/scripts/70-nginx.sh

27 lines
750 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/usr/bin/env bash
set -euo pipefail
source ./lib.sh
NGINX_SITE="/etc/nginx/sites-available/${APP_USER}.conf"
NGINX_SITE_LINK="/etc/nginx/sites-enabled/${APP_USER}.conf"
TEMPLATE="$(cd .. && pwd)/config/nginx/site.conf.tmpl"
# Platzhalter für Template
export APP_DIR
export UI_SSL_DIR="/etc/ssl/ui"
export UI_CERT="${UI_SSL_DIR}/fullchain.pem"
export UI_KEY="${UI_SSL_DIR}/privkey.pem"
export NGINX_HTTP2_SUFFIX
# Template -> Site
log "Nginx konfigurieren…"
envsubst '$APP_DIR $UI_CERT $UI_KEY $NGINX_HTTP2_SUFFIX' < "$TEMPLATE" > "$NGINX_SITE"
ln -sf "$NGINX_SITE" "$NGINX_SITE_LINK"
if nginx -t; then
systemctl enable --now nginx
systemctl reload nginx || true
else
die "Nginx-Konfiguration fehlerhaft /var/log/nginx prüfen."
fi