CRITICAL INFRA
Loading critical CVEs…
ALL EXPLOITED
Loading…

HowTo: Debian + Nginx-Webserver von Grund auf

📅 2026-09-13 · Cyber Immunity

Ein Debian + Nginx-Webserver, vom frischen System bis HTTPS, mit Copy-Paste-Befehlen. Getestet auf Debian 12/13.

1. System aktualisieren

sudo apt update && sudo apt -y full-upgrade
sudo apt -y install curl gnupg ca-certificates

2. Nginx installieren

sudo apt -y install nginx
sudo systemctl enable --now nginx
systemctl status nginx --no-pager

3. Firewall (UFW)

sudo apt -y install ufw
sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'   # 80 + 443
sudo ufw --force enable

4. Document-Root und Rechte

sudo mkdir -p /var/www/example.com/public
sudo chown -R www-data:www-data /var/www/example.com
echo '<h1>OK example.com</h1>' | sudo tee /var/www/example.com/public/index.html

5. Server-Block (Site)

sudo tee /etc/nginx/sites-available/example.com >/dev/null <<'EOF'
server {
    listen 80;
    server_name example.com www.example.com;
    root /var/www/example.com/public;
    index index.html;
    location / { try_files $uri $uri/ =404; }
}
EOF

6. Site aktivieren und testen

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo rm -f /etc/nginx/sites-enabled/default
sudo nginx -t
sudo systemctl reload nginx

7. TLS mit Let's Encrypt

sudo apt -y install certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com --agree-tos -m admin@example.com --redirect
sudo certbot renew --dry-run

8. Pruefen

curl -I http://example.com
curl -I https://example.com
sudo nginx -T | grep server_name

Schnelles Hardening (Header + gzip)

Zwei sofortige Verbesserungen: gzip-Kompression (kleinere Seiten) und Security-Header (Clickjacking-/Sniffing-Schutz + erzwungenes HTTPS).

# gzip (in http {} din /etc/nginx/nginx.conf)
gzip on;
gzip_types text/plain text/css application/javascript application/json image/svg+xml;

# headere de securitate (in server {})
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

nginx -t && systemctl reload nginx

Fazit

Sie haben nun einen funktionierenden Webserver mit HTTPS und Auto-Erneuerung. Wir sichern und ueberwachen ihn fuer Sie.

Lassen Sie uns über Ihr Projekt sprechen →