« Ovh letsencrypt » : différence entre les versions
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| (Une version intermédiaire par le même utilisateur non affichée) | |||
| Ligne 137 : | Ligne 137 : | ||
=== 🔧 Solution A === | === 🔧 Solution A === | ||
----- | ----- | ||
`certbot/certbot:v2.9.0` | |||
==== 1️⃣ Créer le Dockerfile ==== | ==== 1️⃣ Créer le Dockerfile ==== | ||
| Ligne 220 : | Ligne 220 : | ||
</syntaxhighlight> | </syntaxhighlight> | ||
✅ '''Avantages :''' | |||
* Plugin OVH fonctionne immédiatement | |||
* Debian 13 reste intact → pas de pip system-wide ni Snap | |||
* Certificats wildcard Let’s Encrypt générés et renouvelables automatiquement | |||
* Compatible MariaDB, Nginx, Apache | |||
----- | ----- | ||
=== 🔧 Solution B (à tester) === | |||
`certbot/dns-ovh:latest` | |||
==== ✅ '''1. Script <code>initial.sh</code> – Création initiale du certificat''' ==== | |||
Ce script va lancer la commande <code>certonly</code> avec les bons paramètres pour générer un certificat wildcard via OVH : | |||
<syntaxhighlight lang="bash">#!/bin/bash | |||
# Création initiale du certificat Let's Encrypt via Docker | |||
DOMAIN="example.com" | |||
EMAIL="john@gmail.com" | |||
LOGFILE="/var/log/certbot-initial-docker.log" | |||
FROM="cron letsencrypt <john@exemple.com>" | |||
# Nettoyage du log | |||
echo "" > "$LOGFILE" | |||
cd /home/debian/certbot-docker/ | |||
# Lancer la création du certificat | |||
docker compose run --rm certbot certonly \ | |||
--dns-ovh \ | |||
--dns-ovh-credentials /secrets/ovh.ini \ | |||
--dns-ovh-propagation-seconds 60 \ | |||
--non-interactive \ | |||
--agree-tos \ | |||
-d "$DOMAIN" \ | |||
-d "*.$DOMAIN" \ | |||
--email "$EMAIL" \ | |||
--no-eff-email >> "$LOGFILE" 2>&1 | |||
RESULT=$? | |||
< | if [ $RESULT -eq 0 ]; then | ||
systemctl reload apache2 | |||
mail -a "From: $FROM" -s "✅ CERTBOT Création réussie (Docker) pour $DOMAIN" "$EMAIL" < "$LOGFILE" | |||
else | |||
mail -a "From: $FROM" -s "❌ CERTBOT Création ÉCHEC (Docker) pour $DOMAIN" "$EMAIL" < "$LOGFILE" | |||
fi | |||
exit 0</syntaxhighlight> | |||
----- | ----- | ||
==== | ==== 🔁 '''2. Script <code>renew.sh</code> – Renouvellement automatique''' ==== | ||
Voici une version adaptée à l’image <code>certbot/dns-ovh:latest</code> : | |||
<syntaxhighlight lang="bash">#!/bin/bash | |||
# Renouvellement du certificat Let's Encrypt via Docker | |||
LOGFILE="/var/log/certbot-renew-docker.log" | |||
EMAIL="john@gmail.com" | |||
FROM="cron letsencrypt <john@exemple.com>" | |||
# Nettoyage du log | |||
echo "" > "$LOGFILE" | |||
cd /home/debian/certbot-docker/ | |||
----- | # Lancer le renouvellement | ||
docker compose run --rm certbot renew \ | |||
--dns-ovh-credentials /secrets/ovh.ini \ | |||
--dns-ovh-propagation-seconds 60 >> "$LOGFILE" 2>&1 | |||
= | RESULT=$? | ||
< | if [ $RESULT -eq 0 ]; then | ||
systemctl reload apache2 | |||
mail -a "From: $FROM" -s "✅ CERTBOT Renew réussi (Docker)" "$EMAIL" < "$LOGFILE" | |||
else | |||
mail -a "From: $FROM" -s "❌ CERTBOT Renew ÉCHEC (Docker)" "$EMAIL" < "$LOGFILE" | |||
fi | |||
exit 0</syntaxhighlight> | |||
----- | ----- | ||
==== | ==== 🧾 Résumé des étapes à suivre ==== | ||
===== 📁 1. '''Préparer les fichiers''' ===== | |||
<syntaxhighlight lang=" | * Crée un dossier <code>certbot-docker</code> avec : | ||
** <code>docker-compose.yml</code> | |||
** <code>initial.sh</code> | |||
** <code>renew.sh</code> | |||
** Un dossier <code>secrets/</code> contenant <code>ovh.ini</code> avec les clés API : | |||
<syntaxhighlight lang="ini">dns_ovh_endpoint = ovh-eu | |||
dns_ovh_application_key = xxx | |||
dns_ovh_application_secret = xxx | |||
dns_ovh_consumer_key = xxx</syntaxhighlight> | |||
<blockquote>⚠️ Donne les bons droits : <code>chmod 600 secrets/ovh.ini</code> | |||
</blockquote> | |||
----- | ----- | ||
==== | ===== 🐳 2. '''Contenu du <code>docker-compose.yml</code>''' ===== | ||
<syntaxhighlight lang="yaml">version: "3.8" | |||
services: | |||
certbot: | |||
image: certbot/dns-ovh:latest | |||
container_name: certbot-ovh | |||
volumes: | |||
- "/etc/letsencrypt:/etc/letsencrypt" | |||
- "/var/lib/letsencrypt:/var/lib/letsencrypt" | |||
- "./secrets:/secrets" | |||
entrypoint: ""</syntaxhighlight> | |||
----- | |||
===== 🛠️ 3. '''Lancer la création initiale''' ===== | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash">chmod +x initial.sh | ||
./initial.sh</syntaxhighlight> | |||
----- | ----- | ||
===== 🔁 4. '''Configurer le renouvellement automatique'''===== | |||
Ajoute dans <code>crontab -e</code> : | |||
<syntaxhighlight lang="bash">0 3 * * * /home/debian/certbot-docker/renew.sh</syntaxhighlight> | |||
----- | ----- | ||
[[category:ovh]] [[category:Docker]] [[category:Debian]] | [[category:ovh]] [[category:Docker]] [[category:Debian]] | ||