#!/usr/bin/env bash
# install-nginx.sh
# Nginx — High-performance web server, reverse proxy, and load balancer.
# Target: Ubuntu / Debian. Safe to re-run.
# Source guide: devops-hub/tools/nginx.html

set -euo pipefail

if [[ $EUID -eq 0 ]]; then
  echo "Run this as a regular sudo-capable user, not root." >&2
  exit 1
fi

echo "==> Update package index"
sudo apt update

echo "==> Install Nginx"
sudo apt install -y nginx

echo "==> Enable and start the service"
sudo systemctl enable --now nginx

echo "==> Allow HTTP/HTTPS through the firewall"
sudo ufw allow 'Nginx Full'

echo "==> Done. Nginx installation finished."
