Установка Certbot.
1. Для установки Certbot необходимо сначала установить репозиторий epel-release, командой:
yum install epel-release
2. Установим Certbot и скрипт для веб-сервера
Nginx:
yum install certbot python2-certbot-nginx
Apache:
yum install certbot python2-certbot-apache
Получение сертификата Let’s Encrypt.
3. Выполняем команду, которая выполнит запрос на получение SSL-сертификата для веб-сервера Nginx:
certbot --nginx
для Apache:
# certbot --apache
После ввода команды мы должны получить вывод с просьбой указать e-mail, где указываем свой почтовый ящик и нажимаем Enter:
# Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices)
(Enter 'c' to cancel): email@email.ru
4. После ввода e-mail нам предлагается ознакомиться и подтвердить лицензионное соглашение, нажав «Y»:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
5. Снова видим запрос на публикацию введенного e-mail, который отклоняем клавишей «N» и видимо сообщение «Аккаунт зарегистрирован»:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing, once your first certificate is successfully issued, to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: N Account registered.
6. На этом шаге Certbot исследует конфигурационный файл и директорию веб-сервера и должен найти домен сайта. Если на сервере несколько доменов, то он отразит все, из которых надо будет выбрать необходимый соответствующей клавишей:
Which names would you like to activate HTTPS for? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: site.ru 2: site2.ru - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown (Enter 'c' to cancel): 1
и получаем ответ, где говорится, что сертификат развернут и запросы на 80 порт (http) перенаправляются на 443 (https). Может открыть страницу сайта в браузере и убедиться, что адресная строка с https://.
Deploying certificate to virtualhost /etc/nginx/sites-enabled/site
Traffic on port 80 already redirecting to ssl in /etc/nginx/sites-enabled/site
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! Your have sucessfully enabled https://site.ru
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
8. Для контрольной проверки введем команду, которая принудительно перевыпустит сертификат:
certbot renew --dry-run
Автообновление сертификатов через Certbot
9. Сертификат Let’s Encrypt действует 90 дней, процесс перевыпуска автоматизировать. Для этого создадим таймер обновления certbot:
sudo systemctl enable --now certbot-renew.timer
ответ:
Created symlink from /etc/systemd/system/timers.target.wants/certbot-renew.timer to /usr/lib/systemd/system/certbot-renew.timer.
Проверка статуса таймера:
sudo systemctl status certbot-renew.timer
certbot-renew.timer - This is the timer to set the schedule for automated renewals Loaded: loaded (/usr/lib/systemd/system/certbot-renew.timer; enabled; vendor preset: disabled) Active: active (waiting) since Wed 2021-04-07 23:05:10 MSK; 20s ago
Завершение установки
10. Веб-сервер NGINX нужно перезагрузить. Перейдем к файлу /etc/sysconfig/certbot:
vi /etc/sysconfig/certbot
в открывшемся файле находим параметр POST_HOOK и добавляем к нему команду на перезагрузку Nginx после перевыпуска сертификата.
POST_HOOK="--post-hook 'systemctl reload nginx'"
12. Проверка статуса таймера:
sudo systemctl status certbot-renew.timer