Проверить сертификат Let's Encrypt: SSL Labs
apt install certbot python3-certbot-nginx
Убедитесь, что у вас есть рабочий конфиг Nginx для вашего сайта (например, /etc/nginx/sites-available/your_project).
server {
listen 80;
server_name your-domain.com www.your-domain.com;
location / {
proxy_pass http://localhost:8000; # Порт вашего Python-приложения
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
Проверьте синтаксис и перезапустите Nginx
nginx -t systemctl reload nginx
Запустите Certbot с плагином для Nginx
certbot --nginx -d your-domain.com -d www.your-domain.com
Certbot автоматически:
Certbot изменит ваш конфиг, добавив SSL-настройки. Пример итогового файла
server {
listen 443 ssl;
server_name your-domain.com www.your-domain.com;
ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
location / {
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 80;
server_name your-domain.com www.your-domain.com;
return 301 https://$host$request_uri;
}
Certbot добавляет задание в cron для автоматического обновления сертификатов. Проверить можно так
certbot renew --dry-run
sudo systemctl restart nginx
apt install certbot python3-certbot-apache
Запустите Certbot в режиме Apache
certbot --apache
Certbot предложит:
После успешного выполнения Certbot автоматически:
certbot renew --dry-run
certbot renew
Certbot изменяет конфиги Apache, например:
/etc/apache2/sites-available/ваш_сайт.conf (Debian/Ubuntu)/etc/httpd/conf.d/ваш_сайт.conf (CentOS/RHEL)Там должны быть строки
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/ваш_домен/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/ваш_домен/privkey.pem
# Другие настройки...
</VirtualHost>
# Для Ubuntu/Debian sudo systemctl restart apache2 # Для CentOS/RHEL sudo systemctl restart httpd
Указать имя
certbot revoke --cert-name example.com
Или указать путь
certbot revoke --cert-path /etc/letsencrypt/live/example.com/cert.pem
Указать имя
certbot delete --cert-name example.com
Или из списка
certbot delete