Retourner sur le site

Nginx et Certbot (Let's Encrypt)

Servez un site en HTTPS sur votre VPS HolyCloud avec Nginx et des certificats Let's Encrypt automatiques via Certbot.

Nginx et Certbot (Let's Encrypt)

Associez Nginx (serveur web / reverse proxy) et Certbot pour obtenir des certificats Let's Encrypt gratuits et renouvelés automatiquement sur votre VPS Linux HolyCloud.

Prérequis

  • VPS HolyCloud avec Ubuntu/Debian, accès sudo
  • Nom de domaine pointant vers l'IP du VPS (enregistrement A / AAAA dans votre DNS)
  • Ports 80 et 443 ouverts (UFW + panneau HolyCloud)
  • Site ou au minimum un server_name prêt à répondre

Étape 1 : installation de Nginx

sudo apt update
sudo apt install -y nginx
sudo systemctl enable --now nginx
curl -I http://127.0.0.1

Étape 2 : virtual host de base

Remplacez www.example.com par votre domaine :

sudo nano /etc/nginx/sites-available/example.com
server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;
    root /var/www/example.com/html;
    index index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }
}
sudo mkdir -p /var/www/example.com/html
echo '<h1>HolyCloud VPS</h1>' | sudo tee /var/www/example.com/html/index.html
sudo ln -sf /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx

Étape 3 : installation de Certbot (plugin Nginx)

sudo apt install -y certbot python3-certbot-nginx

Étape 4 : obtention du certificat

sudo certbot --nginx -d example.com -d www.example.com --agree-tos -m [email protected] --redirect

Certbot modifie le vhost pour écouter en 443 et redirige HTTP → HTTPS si --redirect est utilisé.

Renouvellement sec (dry-run) :

sudo certbot renew --dry-run

Le timer systemd certbot.timer gère le renouvellement automatique :

systemctl list-timers | grep certbot

Étape 5 : en-têtes TLS recommandés (optionnel)

Après la première émission, renforcez le bloc SSL dans le vhost généré (exemple) :

ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
sudo nginx -t && sudo systemctl reload nginx

Vérification

sudo certbot certificates
curl -sI https://example.com | grep -E 'HTTP/|strict-transport'
openssl s_client -connect example.com:443 -servername example.com </dev/null 2>/dev/null | openssl x509 -noout -dates

Navigateur : cadenas valide, chaîne Let's Encrypt.

Besoin d'aide HolyCloud

  • Challenge failed : vérifiez le DNS (propagation), que le port 80 atteint bien le VPS (pas de proxy CDN bloquant le HTTP-01)
  • Too many requests : limite Let's Encrypt — attendez ou utilisez le staging certbot --staging
  • Support HolyCloud : domaine, IP du VPS, sortie sudo certbot renew --dry-run et nginx -t