refactor: restructure nginx config into per-app files #1

Merged
naomi merged 13 commits from feat/restructure into main 2026-03-07 02:05:29 -08:00
2 changed files with 12 additions and 16 deletions
Showing only changes of commit 493d758df8 - Show all commits
-2
View File
@@ -1,6 +1,4 @@
server { server {
listen 80;
listen [::]:80;
listen 443 ssl; listen 443 ssl;
listen [::]:443 ssl; listen [::]:443 ssl;
+11 -13
View File
@@ -101,21 +101,19 @@ done
echo "" echo ""
# ────────────────────────────────────────────────────────────────── # ──────────────────────────────────────────────────────────────────
# 6. Any port-80 listener must also have a port-443 listener in the # 6. No port-80 listeners in any custom server block
# same file (HTTP-only serving is not acceptable for real sites) # (port 80 is blocked at the firewall; all traffic is HTTPS only)
# ────────────────────────────────────────────────────────────────── # ──────────────────────────────────────────────────────────────────
echo "--- HTTP-only server block check ---" echo "--- Port 80 listener check ---"
http_only_errors=0 http_blocks=$(grep -rnP 'listen\s.*\b80\b' "$NGINX_DIR/sites-available/" \
for conf in "$NGINX_DIR/sites-available/"*.conf; do | grep -v 'sites-available/default' \
[ "$(basename "$conf")" = "default" ] && continue | grep -v '^\s*#' || true)
has_80=$(grep -cP 'listen\s.*\b80\b' "$conf" 2>/dev/null || true) if [ -n "$http_blocks" ]; then
has_443=$(grep -c 'listen 443' "$conf" 2>/dev/null || true) fail "Port 80 listeners found in custom site configs:"
if [ "${has_80:-0}" -gt 0 ] && [ "${has_443:-0}" -eq 0 ]; then printf '%s\n' "$http_blocks" | sed 's/^/ /'
fail "$(basename "$conf"): listens on port 80 but has no port-443 listener" else
http_only_errors=1 pass "No port 80 listeners in custom server blocks"
fi fi
done
[ "$http_only_errors" -eq 0 ] && pass "No HTTP-only server blocks in custom sites"
echo "" echo ""
# ────────────────────────────────────────────────────────────────── # ──────────────────────────────────────────────────────────────────