NGINX SSL mit Let's Encrypt
Lerne, wie du deinen NGINX-Webserver mit einem kostenlosen SSL-Zertifikat von Let's Encrypt absicherst.
Learn how to secure your NGINX web server with a free SSL certificate from Let's Encrypt.
Certbot installieren
Install Certbot
Installiere Certbot und das NGINX-Plugin, um automatisch SSL-Zertifikate zu erhalten und zu konfigurieren.
Install Certbot and the NGINX plugin to automatically obtain and configure SSL certificates.
sudo apt update
sudo apt install certbot python3-certbot-nginxSSL-Zertifikat beantragen
Obtain SSL Certificate
Fordere ein SSL-Zertifikat für deine Domain an. Certbot konfiguriert NGINX automatisch.
Request an SSL certificate for your domain. Certbot will automatically configure NGINX.
sudo certbot --nginx -d domain.comErsetze domain.com mit deiner eigenen Domain. Certbot fragt nach deiner E-Mail-Adresse und ob du HTTP auf HTTPS umleiten möchtest.
Replace domain.com with your own domain. Certbot will ask for your email address and whether you want to redirect HTTP to HTTPS.
HTTPS überprüfen
Verify HTTPS
Öffne deinen Browser und navigiere zu https://domain.com. Du solltest ein gültiges SSL-Zertifikat sehen (Schloss-Symbol in der Adressleiste).
Open your browser and navigate to https://domain.com. You should see a valid SSL certificate (lock icon in the address bar).
Du kannst auch folgenden Befehl verwenden, um die Konfiguration zu testen:
You can also use the following command to test the configuration:
sudo nginx -tAutomatische Erneuerung prüfen
Check Auto-Renewal
Let's Encrypt-Zertifikate sind 90 Tage gültig. Certbot richtet automatisch einen Timer oder Cron-Job für die Erneuerung ein.
Let's Encrypt certificates are valid for 90 days. Certbot automatically sets up a timer or cron job for renewal.
sudo systemctl status certbot.timerFalls kein Timer vorhanden ist, kannst du einen Cron-Job einrichten:
If no timer is present, you can set up a cron job:
sudo crontab -e
# Füge folgende Zeile hinzu / Add the following line:
0 3 * * * certbot renew --quietErneuerung testen
Test Renewal
Teste die automatische Erneuerung mit einem Trockenlauf, um sicherzustellen, dass alles funktioniert.
Test the automatic renewal with a dry run to make sure everything works correctly.
sudo certbot renew --dry-runWenn der Test erfolgreich ist, werden deine Zertifikate automatisch erneuert, bevor sie ablaufen. ✅
If the test succeeds, your certificates will be automatically renewed before they expire. ✅