Установка Certbot для Nginx на Ubuntu для работы с HTTPS

#22  понедельник, 17 июля 2023 г.  5 минут(ы)  413 слов

Обновите пакетный менеджер:

sudo apt-get update

Установите Certbot и плагин Nginx:

sudo apt-get install certbot python3-certbot-nginx

Получите SSL-сертификат и настройте Nginx, заменив yourdomain.com на ваш домен:

sudo certbot --nginx -d yourdomain.com

Пример для домена и поддоменов:

sudo certbot --nginx -d pixelrobot.ru -d api.pixelrobot.ru -d test.pixelrobot.ru -d www.pixelrobot.ru

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): d00m4ace79@gmail.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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.
Requesting a certificate for pixelrobot.ru and 3 more domains

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/pixelrobot.ru/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/pixelrobot.ru/privkey.pem
This certificate expires on 2023-10-15.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

Deploying certificate
Successfully deployed certificate for pixelrobot.ru to /etc/nginx/sites-enabled/default
Successfully deployed certificate for api.pixelrobot.ru to /etc/nginx/sites-enabled/default
Successfully deployed certificate for test.pixelrobot.ru to /etc/nginx/sites-enabled/default
Successfully deployed certificate for www.pixelrobot.ru to /etc/nginx/sites-enabled/default
Congratulations! You have successfully enabled HTTPS on https://pixelrobot.ru, https://api.pixelrobot.ru, https://test.pixelrobot.ru, and https://www.pixelrobot.ru