Устанавливаем пакет certbot
apt-get install certbot
Добавляем в конфиг nginx сайта
location ~ /.well-known {
allow all;
}
Создаем директорию .well-known, чтобы она была доступна по http.
Перечитываем конфиг nginx.
service nginx reload
Осуществляем тестовый запуск. Для проверки используем ключ —dry-run
certbot certonly --dry-run -d site.ru -d www.site.ru
Скрипт задаст несколько вопросов.
How would you like to authenticate with the ACME CA?
1: Place files in webroot directory (webroot)
2: Spin up a temporary webserver (standalone)
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
1: Enter a new webroot
Press 1 [enter] to confirm the selection (press 'c' to cancel): 1
Input the webroot for selux.ru: (Enter 'c' to cancel):/var/www/site.ru/www
Select the webroot for www.selux.ru:
1: Enter a new webroot
2: /var/www/site.ru/www
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Waiting for verification…
Cleaning up challenges
IMPORTANT NOTES:
The dry run was successful.
Необходимо учесть, что для успешного прохождения проверки —dry-run сайт должен быть доступен по адресам, указанным в параметрах —d команды certbot. Т.е., если ваш сайт доступен без www, то в настройках днс необходимо добавить добавить www и в настройках веб-сервера указать домен с www. При необходимости можно указать редирект на основное зеркало.
Запускаем команду получения сертификата:
certbot certonly -d site.ru -d www.site.ru
Saving debug log to /var/log/letsencrypt/letsencrypt.log
How would you like to authenticate with the ACME CA?
1: Spin up a temporary webserver (standalone)
2: Place files in webroot directory (webroot)
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Plugins selected: Authenticator webroot, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for site.ru
http-01 challenge for www.site.ru
Input the webroot for site.ru: (Enter 'c' to cancel): /var/www/site.ru/www
Select the webroot for www.site.ru:
1: Enter a new webroot
2: /var/www/site.ru/www
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Waiting for verification…
Cleaning up challenges
IMPORTANT NOTES:
Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/site.ru/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/site.ru/privkey.pem
Your cert will expire on 2019-05-20. To obtain a new or tweaked
version of this certificate in the future, simply run certbot
again. To non-interactively renew all of your certificates, run
"certbot renew"
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
После успешного формирования файлов необходимо добавить в конфиг nginx для нужного сайта.
Если все ок, запускаем без
ssl_certificate /etc/letsencrypt/live/site.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/site.ru/privkey.pem;