Certbot plugin to handle selectel DNS challenge
634
Automated SSL/TLS certificate issuance and renewal for domains hosted on Selectel DNS using Let's Encrypt via Certbot with DNS-01 challenge.
*.yourdomain.comCreate a file named selectel.ini with your Selectel API credentials:
# Selectel API credentials
dns_selectel_api_v2_account_id = YOUR_ACCOUNT_ID
dns_selectel_api_v2_project_name = YOUR_PROJECT_NAME
dns_selectel_api_v2_username = YOUR_SERVICE_USER
dns_selectel_api_v2_password = "YOUR_PASSWORD"
Important Notes:
#, ;, or spaces), wrap it in quoteschmod 600 selectel.inidocker run --rm \
-v /etc/letsencrypt:/etc/letsencrypt \
-v /var/log/letsencrypt:/var/log/letsencrypt \
-v $(pwd)/selectel.ini:/etc/letsencrypt/selectel.ini:ro \
falcon4ik007/selectel-dns-certbot:latest \
certonly \
-a dns-selectel-api-v2 \
--dns-selectel-api-v2-credentials /etc/letsencrypt/selectel.ini \
--dns-selectel-api-v2-propagation-seconds 120 \
-d yourdomain.com \
--email [email protected] \
--agree-tos \
--non-interactive
docker run --rm \
-v /etc/letsencrypt:/etc/letsencrypt \
-v /var/log/letsencrypt:/var/log/letsencrypt \
-v $(pwd)/selectel.ini:/etc/letsencrypt/selectel.ini:ro \
falcon4ik007/selectel-dns-certbot:latest \
certonly \
-a dns-selectel-api-v2 \
--dns-selectel-api-v2-credentials /etc/letsencrypt/selectel.ini \
--dns-selectel-api-v2-propagation-seconds 120 \
-d yourdomain.com \
-d '*.yourdomain.com' \
--email [email protected] \
--agree-tos \
--non-interactive
After successful issuance, certificates will be located at:
/etc/letsencrypt/live/yourdomain.com/
āāā cert.pem # Your domain certificate
āāā chain.pem # Certificate chain
āāā fullchain.pem # cert.pem + chain.pem
āāā privkey.pem # Private key (keep secure!)
Create a script /opt/certbot/renew-certs.sh:
#!/bin/bash
docker run --rm \
-v /etc/letsencrypt:/etc/letsencrypt \
-v /var/log/letsencrypt:/var/log/letsencrypt \
-v /opt/certbot/selectel.ini:/etc/letsencrypt/selectel.ini:ro \
falcon4ik007/selectel-dns-certbot:latest \
renew \
--dns-selectel-api-v2-credentials /etc/letsencrypt/selectel.ini
Make it executable:
chmod +x /opt/certbot/renew-certs.sh
Create docker-compose.yml:
version: '3.8'
services:
certbot:
image: falcon4ik007/selectel-dns-certbot:latest
volumes:
- /etc/letsencrypt:/etc/letsencrypt
- /var/log/letsencrypt:/var/log/letsencrypt
- ./selectel.ini:/etc/letsencrypt/selectel.ini:ro
command: >
certonly
-a dns-selectel-api-v2
--dns-selectel-api-v2-credentials /etc/letsencrypt/selectel.ini
--dns-selectel-api-v2-propagation-seconds 120
-d yourdomain.com
-d '*.yourdomain.com'
--email [email protected]
--agree-tos
--non-interactive
Run:
docker-compose run --rm certbot
Add to crontab (crontab -e):
# Renew certificates twice daily at 3am and 3pm
0 3,15 * * * /opt/certbot/renew-certs.sh >> /var/log/letsencrypt/renewal.log 2>&1
# Reload nginx after renewal (if needed)
5 3,15 * * * docker exec nginx nginx -s reload
DNS propagation time (default: 120 seconds). Increase if DNS updates are slow:
--dns-selectel-api-v2-propagation-seconds 180
Test certificate issuance without actually requesting a certificate:
docker run --rm \
-v $(pwd)/selectel.ini:/etc/letsencrypt/selectel.ini:ro \
falcon4ik007/selectel-dns-certbot:latest \
certonly --dry-run \
-a dns-selectel-api-v2 \
--dns-selectel-api-v2-credentials /etc/letsencrypt/selectel.ini \
-d yourdomain.com \
--email [email protected] \
--agree-tos \
--non-interactive
For debugging:
docker run --rm \
-v /etc/letsencrypt:/etc/letsencrypt \
-v $(pwd)/selectel.ini:/etc/letsencrypt/selectel.ini:ro \
falcon4ik007/selectel-dns-certbot:latest \
certonly -v \
-a dns-selectel-api-v2 \
--dns-selectel-api-v2-credentials /etc/letsencrypt/selectel.ini \
-d yourdomain.com \
--email [email protected] \
--agree-tos \
--non-interactive
Create a ConfigMap for credentials:
apiVersion: v1
kind: Secret
metadata:
name: selectel-credentials
type: Opaque
stringData:
selectel.ini: |
dns_selectel_api_v2_account_id = YOUR_ACCOUNT_ID
dns_selectel_api_v2_project_name = YOUR_PROJECT_NAME
dns_selectel_api_v2_username = YOUR_SERVICE_USER
dns_selectel_api_v2_password = "YOUR_PASSWORD"
Create a CronJob:
apiVersion: batch/v1
kind: CronJob
metadata:
name: certbot-renewal
spec:
schedule: "0 3 * * *" # Daily at 3am
jobTemplate:
spec:
template:
spec:
containers:
- name: certbot
image: falcon4ik007/selectel-dns-certbot:latest
command:
- certbot
- renew
- --dns-selectel-api-v2-credentials
- /etc/letsencrypt/selectel.ini
volumeMounts:
- name: letsencrypt
mountPath: /etc/letsencrypt
- name: credentials
mountPath: /etc/letsencrypt/selectel.ini
subPath: selectel.ini
readOnly: true
volumes:
- name: letsencrypt
persistentVolumeClaim:
claimName: letsencrypt-pvc
- name: credentials
secret:
secretName: selectel-credentials
restartPolicy: OnFailure
Solution: Set proper permissions on your credentials file:
chmod 600 selectel.ini
Possible causes:
Solution:
selectel.iniPossible causes:
Solution:
Check logs:
docker run --rm \
-v /etc/letsencrypt:/etc/letsencrypt \
-v /var/log/letsencrypt:/var/log/letsencrypt \
falcon4ik007/selectel-dns-certbot:latest \
renew --dry-run
Protect Credentials File
chmod 600 selectel.ini
chown root:root selectel.ini
Use Read-Only Mount
-v $(pwd)/selectel.ini:/etc/letsencrypt/selectel.ini:ro
Restrict Service User Permissions
Regular Certificate Monitoring
Backup Certificates
tar -czf letsencrypt-backup-$(date +%Y%m%d).tar.gz /etc/letsencrypt
server {
listen 443 ssl http2;
server_name yourdomain.com;
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
# Your server configuration...
}
<VirtualHost *:443>
ServerName yourdomain.com
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/yourdomain.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/yourdomain.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/yourdomain.com/chain.pem
# Your server configuration...
</VirtualHost>
latest - Latest stable versionv1.0.0 - Specific versionThis image includes fixes for the original certbot-dns-selectel-api-v2 plugin:
# characterBased on certbot-dns-selectel-api-v2 by Alexey Remizov (Apache License 2.0)
For issues and questions:
/var/log/letsencrypt/letsencrypt.logNote: DNS-01 challenge does not require your domain to point to the server running certbot. The challenge is completed entirely through DNS records, making it perfect for internal networks and wildcard certificates.
Content type
Image
Digest
sha256:060ec0a2eā¦
Size
83.4 MB
Last updated
9 months ago
docker pull falcon4ik007/selectel-dns-certbot