<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SSL域名证书归档 - 博韬</title>
	<atom:link href="http://www.linuxopen.com/category/%E8%BF%90%E7%BB%B4/ssl%E5%9F%9F%E5%90%8D%E8%AF%81%E4%B9%A6/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.linuxopen.com/category/运维/ssl域名证书/</link>
	<description>运维入门到入土</description>
	<lastBuildDate>Tue, 18 Mar 2025 10:25:13 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>

<image>
	<url>http://www.linuxopen.com/wp-content/uploads/2022/09/cropped-cropped-写-32x32.jpg</url>
	<title>SSL域名证书归档 - 博韬</title>
	<link>http://www.linuxopen.com/category/运维/ssl域名证书/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>开通SSL域名证书并配置自动续期</title>
		<link>http://www.linuxopen.com/20250318/%e5%bc%80%e9%80%9assl%e5%9f%9f%e5%90%8d%e8%af%81%e4%b9%a6%e5%b9%b6%e9%85%8d%e7%bd%ae%e8%87%aa%e5%8a%a8%e7%bb%ad%e6%9c%9f/</link>
					<comments>http://www.linuxopen.com/20250318/%e5%bc%80%e9%80%9assl%e5%9f%9f%e5%90%8d%e8%af%81%e4%b9%a6%e5%b9%b6%e9%85%8d%e7%bd%ae%e8%87%aa%e5%8a%a8%e7%bb%ad%e6%9c%9f/#respond</comments>
		
		<dc:creator><![CDATA[botao]]></dc:creator>
		<pubDate>Tue, 18 Mar 2025 10:25:13 +0000</pubDate>
				<category><![CDATA[SSL域名证书]]></category>
		<category><![CDATA[运维]]></category>
		<guid isPermaLink="false">http://www.linuxopen.com/?p=136</guid>

					<description><![CDATA[<p>安装certbot root@botao:~# apt update root@botao:~# apt in ... <a title="开通SSL域名证书并配置自动续期" class="read-more" href="http://www.linuxopen.com/20250318/%e5%bc%80%e9%80%9assl%e5%9f%9f%e5%90%8d%e8%af%81%e4%b9%a6%e5%b9%b6%e9%85%8d%e7%bd%ae%e8%87%aa%e5%8a%a8%e7%bb%ad%e6%9c%9f/" aria-label="阅读 开通SSL域名证书并配置自动续期">阅读更多</a></p>
<p><a href="http://www.linuxopen.com/20250318/%e5%bc%80%e9%80%9assl%e5%9f%9f%e5%90%8d%e8%af%81%e4%b9%a6%e5%b9%b6%e9%85%8d%e7%bd%ae%e8%87%aa%e5%8a%a8%e7%bb%ad%e6%9c%9f/">开通SSL域名证书并配置自动续期</a>最先出现在<a href="http://www.linuxopen.com">博韬</a>。</p>
]]></description>
										<content:encoded><![CDATA[<h3>安装certbot</h3>
<pre><code class="language-plain">root@botao:~# apt update 
root@botao:~# apt install certbot</code></pre>
<h3>申请单域名证书</h3>
<ul>
<li>注意：需要关闭80端口，否则会报错。如遇未关闭80端口的报错，只需关闭后再次执行申请证书的命令即可。</li>
</ul>
<pre><code class="language-plain">root@botao:~# certbot certonly --standalone -d www.linuxopen.com --http-01-address 0.0.0.0
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Enter email address (used for urgent renewal and security notices)
 (Enter &#039;c&#039; to cancel): botao@linuxopen.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.5-February-24-2025.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&#039;s Encrypt project and the non-profit organization that
develops Certbot? We&#039;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: y

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/www.linuxopen.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/www.linuxopen.com/privkey.pem
   Your certificate will expire on 2025-06-09. 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 &quot;certbot renew&quot;
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let&#039;s Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le
</code></pre>
<h3>配置证书自动续期</h3>
<ul>
<li>证书有效期3个月，可以用脚本+计划任务自动续期。</li>
</ul>
<h4>自动续期脚本</h4>
<ul>
<li>检查证书过期时间小于15天执行证书续期命令</li>
</ul>
<pre><code class="language-plain">root@botao:~# cat /scripts/letsencript/ssl_renew.sh 
#!/bin/bash

daynum=`/usr/bin/certbot certificates | grep days| awk &#039;{print $6}&#039;`
realtime=`date +%Y-%m-%d+%H:%M:%S`

for day in $daynum
do
    if (( $day &lt;= 15 ));
    then
        /usr/bin/systemctl stop nginx &amp;&amp; /usr/bin/certbot renew &gt; /scripts/letsencrypt/certbot-renew.log &amp;&amp; /usr/bin/systemctl start nginx &amp;&amp; echo &quot;$realtime certbot ok&quot; &gt;&gt; /scripts/letsencrypt/end-renew.log
break
    fi
done
</code></pre>
<h4>计划任务</h4>
<ul>
<li>每周三早上10点17分执行证书续期脚本</li>
</ul>
<pre><code class="language-plain">root@botao:~# crontab -l
#Name: letsencrypt SSL自动续期
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
HOME=/scripts/letsencrypt
SHELL=/bin/bash
17 10 * * 3 ./ssl_renew.sh</code></pre>
<h3>nginx配置文件</h3>
<ul>
<li>主要是写清楚证书文件位置和代理端口</li>
</ul>
<pre><code class="language-plain">root@botao:/etc/nginx/conf.d# vim ssl_botao.conf 
server {
    listen 443 ssl;
    server_name linuxopen.com www.linuxopen.com;
    access_log /var/log/nginx/http443.access.log;
    error_log /var/log/nginx/http443.error.log;

        ssl_certificate   /etc/letsencrypt/live/www.linuxopen.com/fullchain.pem;
        ssl_certificate_key  /etc/letsencrypt/live/www.linuxopen.com/privkey.pem;
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;

        add_header Cache-Control no-cache;
        add_header Cache-Control private;

    location / {
            proxy_pass http://127.0.0.1:80;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}
</code></pre>
<p><a href="http://www.linuxopen.com/20250318/%e5%bc%80%e9%80%9assl%e5%9f%9f%e5%90%8d%e8%af%81%e4%b9%a6%e5%b9%b6%e9%85%8d%e7%bd%ae%e8%87%aa%e5%8a%a8%e7%bb%ad%e6%9c%9f/">开通SSL域名证书并配置自动续期</a>最先出现在<a href="http://www.linuxopen.com">博韬</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>http://www.linuxopen.com/20250318/%e5%bc%80%e9%80%9assl%e5%9f%9f%e5%90%8d%e8%af%81%e4%b9%a6%e5%b9%b6%e9%85%8d%e7%bd%ae%e8%87%aa%e5%8a%a8%e7%bb%ad%e6%9c%9f/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
