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 {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
+12 -14
View File
@@ -101,21 +101,19 @@ done
echo ""
# ──────────────────────────────────────────────────────────────────
# 6. Any port-80 listener must also have a port-443 listener in the
# same file (HTTP-only serving is not acceptable for real sites)
# 6. No port-80 listeners in any custom server block
# (port 80 is blocked at the firewall; all traffic is HTTPS only)
# ──────────────────────────────────────────────────────────────────
echo "--- HTTP-only server block check ---"
http_only_errors=0
for conf in "$NGINX_DIR/sites-available/"*.conf; do
[ "$(basename "$conf")" = "default" ] && continue
has_80=$(grep -cP 'listen\s.*\b80\b' "$conf" 2>/dev/null || true)
has_443=$(grep -c 'listen 443' "$conf" 2>/dev/null || true)
if [ "${has_80:-0}" -gt 0 ] && [ "${has_443:-0}" -eq 0 ]; then
fail "$(basename "$conf"): listens on port 80 but has no port-443 listener"
http_only_errors=1
fi
done
[ "$http_only_errors" -eq 0 ] && pass "No HTTP-only server blocks in custom sites"
echo "--- Port 80 listener check ---"
http_blocks=$(grep -rnP 'listen\s.*\b80\b' "$NGINX_DIR/sites-available/" \
| grep -v 'sites-available/default' \
| grep -v '^\s*#' || true)
if [ -n "$http_blocks" ]; then
fail "Port 80 listeners found in custom site configs:"
printf '%s\n' "$http_blocks" | sed 's/^/ /'
else
pass "No port 80 listeners in custom server blocks"
fi
echo ""
# ──────────────────────────────────────────────────────────────────