{"id":459534,"date":"2025-05-13T21:00:30","date_gmt":"2025-05-13T21:00:30","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=459534"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=459534","title":{"rendered":"<span>\u041a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 SSL-\u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 Let\u2019s Encrypt \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Certbot \u043d\u0430 Ubuntu<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u044b \u043d\u0435 \u0434\u0435\u0432\u043e\u043f\u0441. \u0412\u044b \u2014 \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0435\u0431\u0435 \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434\u0435\u0440, \u0431\u044d\u043a\u0435\u043d\u0434\u0435\u0440, \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0436\u0435 \u043c\u043e\u0431\u0438\u043b\u044c\u0449\u0438\u043a. \u041d\u043e \u0432\u043e\u0442 \u0431\u0435\u0434\u0430: \u0443 \u0432\u0430\u0441 \u0441\u0435\u0440\u0432\u0435\u0440, \u0438 \u0435\u043c\u0443 \u043d\u0443\u0436\u0435\u043d SSL. \u0410 \u0434\u0435\u0432\u043e\u043f\u0441 \u0443\u0435\u0445\u0430\u043b \u0432 \u043e\u0442\u043f\u0443\u0441\u043a. \u0418\u043b\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043d\u0430\u043d\u044f\u0442. \u0418 \u0432\u043e\u0442 \u0432\u044b \u0441\u0442\u043e\u0438\u0442\u0435, \u0433\u043b\u044f\u0434\u0438\u0442\u0435 \u043d\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u0438 \u0434\u0443\u043c\u0430\u0435\u0442\u0435: \u00ab\u041d\u0443 \u0432\u0441\u0451, \u0442\u0435\u043f\u0435\u0440\u044c \u044f \u2014 DevOps\u00bb. \ud83d\ude05<\/p>\n<p>\u041f\u0443\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0441\u0442\u043e\u0438\u0442. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c SSL-\u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u043e\u0442 Let\u2019s Encrypt \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Certbot \u043d\u0430 Ubuntu. \u0421 \u0448\u0443\u0442\u043a\u0430\u043c\u0438, \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u0438 bash-\u043c\u0430\u0433\u0438\u0435\u0439.<\/p>\n<hr\/>\n<h4>\ud83d\udd12 \u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d Certbot \u0438 Let\u2019s Encrypt?<\/h4>\n<p>Let\u2019s Encrypt \u2014 \u044d\u0442\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0446\u0435\u043d\u0442\u0440 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0442\u044c SSL-\u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u0434\u043b\u044f HTTPS. Certbot \u2014 \u044d\u0442\u043e \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432.<\/p>\n<p>\u041a\u043e\u043c\u0431\u043e \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0445\u043e\u0447\u0435\u0442 \u0432\u043e\u0437\u0438\u0442\u044c\u0441\u044f \u0441 \u0440\u0443\u0447\u043d\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u043a\u043b\u044e\u0447\u0435\u0439 \u0438 \u043f\u043e\u0445\u043e\u0434\u0430\u043c\u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u0438\u0435 CA.<\/p>\n<hr\/>\n<h4>\ud83d\ude80 \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Certbot<\/h4>\n<pre><code class=\"bash\">sudo apt update sudo apt install certbot<\/code><\/pre>\n<p><strong>\u0412\u0430\u0436\u043d\u043e:<\/strong>\u00a0Certbot \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430 \u0442\u043e\u043c \u0436\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442.<\/p>\n<hr\/>\n<h4>\ud83d\udcdc \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 (\u0438 \u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0442\u0435\u043a\u0443\u0449\u0438\u0445 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u0445)<\/h4>\n<pre><code class=\"bash\">sudo certbot certonly --standalone -d project.com -d www.project.com sudo certbot certificates<\/code><\/pre>\n<ul>\n<li>\n<p><code>--standalone<\/code>\u00a0\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e Certbot \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0434\u043d\u0438\u043c\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 80 \u043f\u043e\u0440\u0442\u0443 \u0434\u043b\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u043e\u043c\u0435\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u043f\u043e\u0440\u0442 80 \u043d\u0435 \u0437\u0430\u043d\u044f\u0442!<\/strong>\u00a0\u0418\u043d\u0430\u0447\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<figure class=\"bordered full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/074\/6b4\/3ce\/0746b43ceafe06711aaf1623dec024fe.png\" width=\"1024\" height=\"1024\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/074\/6b4\/3ce\/0746b43ceafe06711aaf1623dec024fe.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/074\/6b4\/3ce\/0746b43ceafe06711aaf1623dec024fe.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0430\u043c \u0432\u0430\u0448 Nginx \u0438\u043b\u0438 Docker \u2014 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0435\u0433\u043e \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"bash\">sudo systemctl stop nginx<\/code><\/pre>\n<p><strong>\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430:<\/strong>\u00a0\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043b\u0430\u0433\u0438\u043d\u00a0<code>webroot<\/code>\u00a0\u2014 \u043e\u043d \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0441\u0430\u0439\u0442\u0430.<\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u043f\u043b\u0430\u0433\u0438\u043d\u044b \u2014\u00a0<a href=\"https:\/\/eff-certbot.readthedocs.io\/en\/stable\/using.html#getting-certificates-and-choosing-plugins\" rel=\"noopener noreferrer nofollow\">\u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<hr\/>\n<h4>\u23f1 \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 systemd<\/h4>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 Certbot \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 systemd-\u0442\u0430\u0439\u043c\u0435\u0440:<\/p>\n<pre><code class=\"bash\">systemctl list-timers | grep certbot<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430:<\/p>\n<pre><code class=\"bash\">Mon 2025-03-10 03:12:00 UTC  10h left  Mon 2025-03-09 03:12:00 UTC  certbot.timer  certbot.service<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<pre><code class=\"bash\">sudo certbot renew --dry-run<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0451 \u0445\u043e\u0440\u043e\u0448\u043e:<\/p>\n<pre><code class=\"bash\">Certbot dry-run was successful.<\/code><\/pre>\n<p>\u041b\u043e\u0433\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"bash\">journalctl -u certbot.service --no-pager --since \"2 days ago\"<\/code><\/pre>\n<p><strong>\u041d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0435:<\/strong>\u00a0Certbot \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0434\u043e \u0438\u0445 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f &lt; 30 \u0434\u043d\u0435\u0439.<\/p>\n<hr\/>\n<h4>\ud83d\udd70\ufe0f \u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430: \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 Cron<\/h4>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 systemd-\u0442\u0430\u0439\u043c\u0435\u0440\u044b \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u044b, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0435 \u0432\u0441\u0451 \u0447\u0435\u0440\u0435\u0437 Ansible \u0438\u043b\u0438 shell-\u0441\u043a\u0440\u0438\u043f\u0442\u044b. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Cron.<\/p>\n<ol>\n<li>\n<p>\u041e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"bash\">sudo systemctl stop certbot.timer sudo systemctl disable certbot.timer<\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c Cron-\u0437\u0430\u0434\u0430\u0447\u0443:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"bash\">sudo crontab -e<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"bash\">0 0 1 * * \/usr\/bin\/certbot renew --standalone --quiet<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0442\u043e\u0447\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a\u00a0<code>certbot<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435:<\/p>\n<pre><code class=\"bash\">which certbot<\/code><\/pre>\n<hr\/>\n<h4>\u2699\ufe0f \u0425\u0443\u043a\u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432<\/h4>\n<p>Certbot \u0443\u043c\u0435\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u043e, \u043f\u043e\u0441\u043b\u0435 \u0438\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441, \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440.<\/p>\n<pre><code class=\"bash\"># \/etc\/letsencrypt\/renewal\/project.com.conf  pre_hook = systemctl stop my-project.service deploy_hook = systemctl reload my-project.service post_hook = systemctl start my-project.service<\/code><\/pre>\n<hr\/>\n<h4>\ud83d\udee0\ufe0f \u0421\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 \u0432\u0441\u0435 \u0441\u043b\u0443\u0447\u0430\u0438 \u0436\u0438\u0437\u043d\u0438<\/h4>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0433\u043e \u0432 \u043a\u0440\u043e\u043d\u0435, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c bash-\u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442:<\/p>\n<ol>\n<li>\n<p>\u041e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432 \u043d\u0443\u0436\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0430<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u043e\u0431\u0440\u0430\u0442\u043d\u043e<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"bash\">#!\/bin\/bash  APP_PATH=\"\/home\/projects\/project\" DOMAIN=\"project.com\"  FULL_CHAIN_SRC=\"\/etc\/letsencrypt\/live\/${DOMAIN}\/fullchain.pem\" PRIVATE_KEY_SRC=\"\/etc\/letsencrypt\/live\/${DOMAIN}\/privkey.pem\" FULL_CHAIN_DIST=\"${APP_PATH}\/volumes\/etc\/ssl\/certs\/project_com.full.crt\" PRIVATE_KEY_DIST=\"${APP_PATH}\/volumes\/etc\/ssl\/private\/project_com.key\"  echo \"Starting script execution: $(date \"+%Y-%m-%d %H:%M:%S\")\"  echo \"Stopping the service...\" systemctl stop my-project.service  echo \"Renewing the certificates...\" \/usr\/bin\/certbot renew --standalone --quiet \/usr\/bin\/certbot certificates  echo \"Copying the certificates to the project...\" cp -f \"$FULL_CHAIN_SRC\" \"$FULL_CHAIN_DIST\" cp -f \"$PRIVATE_KEY_SRC\" \"$PRIVATE_KEY_DIST\"  echo \"Setting correct permissions for the certificates...\" chmod 644 \"$FULL_CHAIN_DIST\" chmod 644 \"$PRIVATE_KEY_DIST\"  echo \"Running the service...\" systemctl start my-project.service  echo \"End of script execution: $(date \"+%Y-%m-%d %H:%M:%S\")\"<\/code><\/pre>\n<p>\u0410 \u0432 \u043a\u0440\u043e\u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">0 0 1 * * sh \/home\/projects\/project\/cert-renew.sh &gt;&gt; \/var\/log\/project-cert-renew.log 2&gt;&amp;1<\/code><\/pre>\n<hr\/>\n<h4>\ud83e\udde0 \u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0434\u0430\u0436\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u044b\u0442\u044c \u0434\u0435\u0432\u043e\u043f\u0441\u043e\u043c. \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u043d\u0435 \u0431\u043e\u044f\u0442\u044c\u0441\u044f \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430 \u0438 \u0437\u043d\u0430\u0442\u044c, \u0433\u0434\u0435 \u0433\u0443\u0433\u043b\u0438\u0442\u044c. \u0410 \u0435\u0449\u0451 \u2014 \u043d\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u0433\u043e\u0434\u0430, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u0451 \u0435\u0449\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \ud83d\ude01<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0430\u0448\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0443 \u0438\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u2014 \u0432\u0435\u043b\u043a\u043e\u043c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/909164\/\"> https:\/\/habr.com\/ru\/articles\/909164\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u044b \u043d\u0435 \u0434\u0435\u0432\u043e\u043f\u0441. \u0412\u044b \u2014 \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0435\u0431\u0435 \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434\u0435\u0440, \u0431\u044d\u043a\u0435\u043d\u0434\u0435\u0440, \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0436\u0435 \u043c\u043e\u0431\u0438\u043b\u044c\u0449\u0438\u043a. \u041d\u043e \u0432\u043e\u0442 \u0431\u0435\u0434\u0430: \u0443 \u0432\u0430\u0441 \u0441\u0435\u0440\u0432\u0435\u0440, \u0438 \u0435\u043c\u0443 \u043d\u0443\u0436\u0435\u043d SSL. \u0410 \u0434\u0435\u0432\u043e\u043f\u0441 \u0443\u0435\u0445\u0430\u043b \u0432 \u043e\u0442\u043f\u0443\u0441\u043a. \u0418\u043b\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043d\u0430\u043d\u044f\u0442. \u0418 \u0432\u043e\u0442 \u0432\u044b \u0441\u0442\u043e\u0438\u0442\u0435, \u0433\u043b\u044f\u0434\u0438\u0442\u0435 \u043d\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u0438 \u0434\u0443\u043c\u0430\u0435\u0442\u0435: \u00ab\u041d\u0443 \u0432\u0441\u0451, \u0442\u0435\u043f\u0435\u0440\u044c \u044f \u2014 DevOps\u00bb. \ud83d\ude05<\/p>\n<p>\u041f\u0443\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0441\u0442\u043e\u0438\u0442. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c SSL-\u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u043e\u0442 Let\u2019s Encrypt \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Certbot \u043d\u0430 Ubuntu. \u0421 \u0448\u0443\u0442\u043a\u0430\u043c\u0438, \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u0438 bash-\u043c\u0430\u0433\u0438\u0435\u0439.<\/p>\n<hr\/>\n<h4>\ud83d\udd12 \u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d Certbot \u0438 Let\u2019s Encrypt?<\/h4>\n<p>Let\u2019s Encrypt \u2014 \u044d\u0442\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0446\u0435\u043d\u0442\u0440 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0442\u044c SSL-\u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u0434\u043b\u044f HTTPS. Certbot \u2014 \u044d\u0442\u043e \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432.<\/p>\n<p>\u041a\u043e\u043c\u0431\u043e \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0445\u043e\u0447\u0435\u0442 \u0432\u043e\u0437\u0438\u0442\u044c\u0441\u044f \u0441 \u0440\u0443\u0447\u043d\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u043a\u043b\u044e\u0447\u0435\u0439 \u0438 \u043f\u043e\u0445\u043e\u0434\u0430\u043c\u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u0438\u0435 CA.<\/p>\n<hr\/>\n<h4>\ud83d\ude80 \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Certbot<\/h4>\n<pre><code class=\"bash\">sudo apt update sudo apt install certbot<\/code><\/pre>\n<p><strong>\u0412\u0430\u0436\u043d\u043e:<\/strong>\u00a0Certbot \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430 \u0442\u043e\u043c \u0436\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442.<\/p>\n<hr\/>\n<h4>\ud83d\udcdc \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 (\u0438 \u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0442\u0435\u043a\u0443\u0449\u0438\u0445 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u0445)<\/h4>\n<pre><code class=\"bash\">sudo certbot certonly --standalone -d project.com -d www.project.com sudo certbot certificates<\/code><\/pre>\n<ul>\n<li>\n<p><code>--standalone<\/code>\u00a0\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e Certbot \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0434\u043d\u0438\u043c\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 80 \u043f\u043e\u0440\u0442\u0443 \u0434\u043b\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u043e\u043c\u0435\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u043f\u043e\u0440\u0442 80 \u043d\u0435 \u0437\u0430\u043d\u044f\u0442!<\/strong>\u00a0\u0418\u043d\u0430\u0447\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<figure class=\"bordered full-width\"><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0430\u043c \u0432\u0430\u0448 Nginx \u0438\u043b\u0438 Docker \u2014 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0435\u0433\u043e \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"bash\">sudo systemctl stop nginx<\/code><\/pre>\n<p><strong>\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430:<\/strong>\u00a0\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043b\u0430\u0433\u0438\u043d\u00a0<code>webroot<\/code>\u00a0\u2014 \u043e\u043d \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0441\u0430\u0439\u0442\u0430.<\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u043f\u043b\u0430\u0433\u0438\u043d\u044b \u2014\u00a0<a href=\"https:\/\/eff-certbot.readthedocs.io\/en\/stable\/using.html#getting-certificates-and-choosing-plugins\" rel=\"noopener noreferrer nofollow\">\u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<hr\/>\n<h4>\u23f1 \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 systemd<\/h4>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 Certbot \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 systemd-\u0442\u0430\u0439\u043c\u0435\u0440:<\/p>\n<pre><code class=\"bash\">systemctl list-timers | grep certbot<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430:<\/p>\n<pre><code class=\"bash\">Mon 2025-03-10 03:12:00 UTC  10h left  Mon 2025-03-09 03:12:00 UTC  certbot.timer  certbot.service<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<pre><code class=\"bash\">sudo certbot renew --dry-run<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0451 \u0445\u043e\u0440\u043e\u0448\u043e:<\/p>\n<pre><code class=\"bash\">Certbot dry-run was successful.<\/code><\/pre>\n<p>\u041b\u043e\u0433\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"bash\">journalctl -u certbot.service --no-pager --since \"2 days ago\"<\/code><\/pre>\n<p><strong>\u041d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0435:<\/strong>\u00a0Certbot \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0434\u043e \u0438\u0445 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f &lt; 30 \u0434\u043d\u0435\u0439.<\/p>\n<hr\/>\n<h4>\ud83d\udd70\ufe0f \u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430: \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 Cron<\/h4>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 systemd-\u0442\u0430\u0439\u043c\u0435\u0440\u044b \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u044b, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0435 \u0432\u0441\u0451 \u0447\u0435\u0440\u0435\u0437 Ansible \u0438\u043b\u0438 shell-\u0441\u043a\u0440\u0438\u043f\u0442\u044b. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Cron.<\/p>\n<ol>\n<li>\n<p>\u041e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"bash\">sudo systemctl stop certbot.timer sudo systemctl disable certbot.timer<\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c Cron-\u0437\u0430\u0434\u0430\u0447\u0443:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"bash\">sudo crontab -e<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"bash\">0 0 1 * * \/usr\/bin\/certbot renew --standalone --quiet<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0442\u043e\u0447\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a\u00a0<code>certbot<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435:<\/p>\n<pre><code class=\"bash\">which certbot<\/code><\/pre>\n<hr\/>\n<h4>\u2699\ufe0f \u0425\u0443\u043a\u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432<\/h4>\n<p>Certbot \u0443\u043c\u0435\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u043e, \u043f\u043e\u0441\u043b\u0435 \u0438\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441, \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440.<\/p>\n<pre><code class=\"bash\"># \/etc\/letsencrypt\/renewal\/project.com.conf  pre_hook = systemctl stop my-project.service deploy_hook = systemctl reload my-project.service post_hook = systemctl start my-project.service<\/code><\/pre>\n<hr\/>\n<h4>\ud83d\udee0\ufe0f \u0421\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 \u0432\u0441\u0435 \u0441\u043b\u0443\u0447\u0430\u0438 \u0436\u0438\u0437\u043d\u0438<\/h4>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0433\u043e \u0432 \u043a\u0440\u043e\u043d\u0435, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c bash-\u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442:<\/p>\n<ol>\n<li>\n<p>\u041e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432 \u043d\u0443\u0436\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0430<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u043e\u0431\u0440\u0430\u0442\u043d\u043e<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"bash\">#!\/bin\/bash  APP_PATH=\"\/home\/projects\/project\" DOMAIN=\"project.com\"  FULL_CHAIN_SRC=\"\/etc\/letsencrypt\/live\/${DOMAIN}\/fullchain.pem\" PRIVATE_KEY_SRC=\"\/etc\/letsencrypt\/live\/${DOMAIN}\/privkey.pem\" FULL_CHAIN_DIST=\"${APP_PATH}\/volumes\/etc\/ssl\/certs\/project_com.full.crt\" PRIVATE_KEY_DIST=\"${APP_PATH}\/volumes\/etc\/ssl\/private\/project_com.key\"  echo \"Starting script execution: $(date \"+%Y-%m-%d %H:%M:%S\")\"  echo \"Stopping the service...\" systemctl stop my-project.service  echo \"Renewing the certificates...\" \/usr\/bin\/certbot renew --standalone --quiet \/usr\/bin\/certbot certificates  echo \"Copying the certificates to the project...\" cp -f \"$FULL_CHAIN_SRC\" \"$FULL_CHAIN_DIST\" cp -f \"$PRIVATE_KEY_SRC\" \"$PRIVATE_KEY_DIST\"  echo \"Setting correct permissions for the certificates...\" chmod 644 \"$FULL_CHAIN_DIST\" chmod 644 \"$PRIVATE_KEY_DIST\"  echo \"Running the service...\" systemctl start my-project.service  echo \"End of script execution: $(date \"+%Y-%m-%d %H:%M:%S\")\"<\/code><\/pre>\n<p>\u0410 \u0432 \u043a\u0440\u043e\u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">0 0 1 * * sh \/home\/projects\/project\/cert-renew.sh &gt;&gt; \/var\/log\/project-cert-renew.log 2&gt;&amp;1<\/code><\/pre>\n<hr\/>\n<h4>\ud83e\udde0 \u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0434\u0430\u0436\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u044b\u0442\u044c \u0434\u0435\u0432\u043e\u043f\u0441\u043e\u043c. \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u043d\u0435 \u0431\u043e\u044f\u0442\u044c\u0441\u044f \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430 \u0438 \u0437\u043d\u0430\u0442\u044c, \u0433\u0434\u0435 \u0433\u0443\u0433\u043b\u0438\u0442\u044c. \u0410 \u0435\u0449\u0451 \u2014 \u043d\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u0433\u043e\u0434\u0430, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u0451 \u0435\u0449\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \ud83d\ude01<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0430\u0448\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0443 \u0438\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u2014 \u0432\u0435\u043b\u043a\u043e\u043c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/909164\/\"> https:\/\/habr.com\/ru\/articles\/909164\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-459534","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/459534","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=459534"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/459534\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=459534"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=459534"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=459534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}