<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://wiki.linuxsa.org/index.php?action=history&amp;feed=atom&amp;title=Nginx%E5%AE%89%E8%A3%85Let%E2%80%99s_Encrypt%E5%85%8D%E8%B4%B9SSL%E8%AF%81%E4%B9%A6</id>
	<title>Nginx安装Let’s Encrypt免费SSL证书 - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.linuxsa.org/index.php?action=history&amp;feed=atom&amp;title=Nginx%E5%AE%89%E8%A3%85Let%E2%80%99s_Encrypt%E5%85%8D%E8%B4%B9SSL%E8%AF%81%E4%B9%A6"/>
	<link rel="alternate" type="text/html" href="https://wiki.linuxsa.org/index.php?title=Nginx%E5%AE%89%E8%A3%85Let%E2%80%99s_Encrypt%E5%85%8D%E8%B4%B9SSL%E8%AF%81%E4%B9%A6&amp;action=history"/>
	<updated>2026-04-18T09:17:55Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://wiki.linuxsa.org/index.php?title=Nginx%E5%AE%89%E8%A3%85Let%E2%80%99s_Encrypt%E5%85%8D%E8%B4%B9SSL%E8%AF%81%E4%B9%A6&amp;diff=748&amp;oldid=prev</id>
		<title>Evan：​/* 自动更新证书 */</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxsa.org/index.php?title=Nginx%E5%AE%89%E8%A3%85Let%E2%80%99s_Encrypt%E5%85%8D%E8%B4%B9SSL%E8%AF%81%E4%B9%A6&amp;diff=748&amp;oldid=prev"/>
		<updated>2024-03-10T09:10:29Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;自动更新证书&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
=debian 10  201911=&lt;br /&gt;
== Install Certbot  september 2022 ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install certbot python3-certbot-nginx #python-certbot-nginx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== just get a certificate 2022==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#Note  这些域名你得先作个A  不然 生成不了还有 那机器得有 开80 eg ng  Sep 2022&lt;br /&gt;
#注意 这个不是泛域名的呢  我要 wiki 其它有空再搞 &lt;br /&gt;
# sudo certbot certonly --nginx&lt;br /&gt;
Saving debug log to /var/log/letsencrypt/letsencrypt.log&lt;br /&gt;
Plugins selected: Authenticator nginx, Installer nginx&lt;br /&gt;
Enter email address (used for urgent renewal and security notices) (Enter &amp;#039;c&amp;#039; to&lt;br /&gt;
cancel): evan886@gmail.com&lt;br /&gt;
&lt;br /&gt;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -&lt;br /&gt;
Please read the Terms of Service at&lt;br /&gt;
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must&lt;br /&gt;
agree in order to register with the ACME server at&lt;br /&gt;
https://acme-v02.api.letsencrypt.org/directory&lt;br /&gt;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -&lt;br /&gt;
(A)gree/(C)ancel: A&lt;br /&gt;
&lt;br /&gt;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -&lt;br /&gt;
Would you be willing to share your email address with the Electronic Frontier&lt;br /&gt;
Foundation, a founding partner of the Let&amp;#039;s Encrypt project and the non-profit&lt;br /&gt;
organization that develops Certbot? We&amp;#039;d like to send you email about our work&lt;br /&gt;
encrypting the web, EFF news, campaigns, and ways to support digital freedom.&lt;br /&gt;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -&lt;br /&gt;
(Y)es/(N)o: Y&lt;br /&gt;
&lt;br /&gt;
Which names would you like to activate HTTPS for?&lt;br /&gt;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -&lt;br /&gt;
1: linuxchina.net&lt;br /&gt;
2: blog.linuxchina.net&lt;br /&gt;
3: wiki.linuxchina.net&lt;br /&gt;
4: www.linuxchina.net&lt;br /&gt;
5: linuxsa.org&lt;br /&gt;
6: www.linuxsa.org&lt;br /&gt;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -&lt;br /&gt;
Select the appropriate numbers separated by commas and/or spaces, or leave input&lt;br /&gt;
blank to select all options shown (Enter &amp;#039;c&amp;#039; to cancel): 1&lt;br /&gt;
Obtaining a new certificate&lt;br /&gt;
Performing the following challenges:&lt;br /&gt;
http-01 challenge for linuxchina.net&lt;br /&gt;
Waiting for verification...&lt;br /&gt;
Cleaning up challenges&lt;br /&gt;
&lt;br /&gt;
IMPORTANT NOTES:&lt;br /&gt;
 - Congratulations! Your certificate and chain have been saved at:&lt;br /&gt;
   /etc/letsencrypt/live/linuxchina.net/fullchain.pem&lt;br /&gt;
   Your key file has been saved at:&lt;br /&gt;
   /etc/letsencrypt/live/linuxchina.net/privkey.pem&lt;br /&gt;
   Your cert will expire on 2020-02-29. To obtain a new or tweaked&lt;br /&gt;
   version of this certificate in the future, simply run certbot&lt;br /&gt;
   again. To non-interactively renew *all* of your certificates, run&lt;br /&gt;
   &amp;quot;certbot renew&amp;quot;&lt;br /&gt;
 - Your account credentials have been saved in your Certbot&lt;br /&gt;
   configuration directory at /etc/letsencrypt. You should make a&lt;br /&gt;
   secure backup of this folder now. This configuration directory will&lt;br /&gt;
   also contain certificates and private keys obtained by Certbot so&lt;br /&gt;
   making regular backups of this folder is ideal.&lt;br /&gt;
 - If you like Certbot, please consider supporting our work by:&lt;br /&gt;
&lt;br /&gt;
   Donating to ISRG / Let&amp;#039;s Encrypt:   https://letsencrypt.org/donate&lt;br /&gt;
   Donating to EFF:                    https://eff.org/donate-le&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== automatic renewal==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sudo certbot renew --dry-run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
new certificate deployed with reload of nginx server; fullchain is&lt;br /&gt;
/etc/letsencrypt/live/wiki.linuxchina.net/fullchain.pem&lt;br /&gt;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -&lt;br /&gt;
&lt;br /&gt;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -&lt;br /&gt;
** DRY RUN: simulating &amp;#039;certbot renew&amp;#039; close to cert expiry&lt;br /&gt;
**          (The test certificates below have not been saved.)&lt;br /&gt;
&lt;br /&gt;
Congratulations, all renewals succeeded. The following certs have been renewed:&lt;br /&gt;
  /etc/letsencrypt/live/linuxchina.net/fullchain.pem (success)&lt;br /&gt;
  /etc/letsencrypt/live/wiki.linuxchina.net/fullchain.pem (success)&lt;br /&gt;
** DRY RUN: simulating &amp;#039;certbot renew&amp;#039; close to cert expiry&lt;br /&gt;
**          (The test certificates above have not been saved.)&lt;br /&gt;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -&lt;br /&gt;
&lt;br /&gt;
IMPORTANT NOTES:&lt;br /&gt;
 - Your account credentials have been saved in your Certbot&lt;br /&gt;
   configuration directory at /etc/letsencrypt. You should make a&lt;br /&gt;
   secure backup of this folder now. This configuration directory will&lt;br /&gt;
   also contain certificates and private keys obtained by Certbot so&lt;br /&gt;
   making regular backups of this folder is ideal.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==see also==&lt;br /&gt;
https://certbot.eff.org/lets-encrypt/debianbuster-nginx&lt;br /&gt;
&lt;br /&gt;
=2018=&lt;br /&gt;
==第零==&lt;br /&gt;
这里最了的办法了，不用再去理其它了，昨天就看了别的 搞了半天s呀 20170627&lt;br /&gt;
&lt;br /&gt;
今天用了另外一个方法 20170125&lt;br /&gt;
&amp;lt;pre&amp;gt;pkg install py27-certbot&lt;br /&gt;
&lt;br /&gt;
certbot certonly --standalone -d wiki.linuxchina.net  -d blog.linuxchina.net &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==自动更新证书==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
service nginx stop  &amp;amp;&amp;amp; certbot renew &amp;amp;&amp;amp; service nginx start&lt;br /&gt;
&lt;br /&gt;
#这个是别人的写法 也是不错 &lt;br /&gt;
echo &amp;#039;0 3 * */2 * certbot renew --pre-hook &amp;quot;service nginx stop&amp;quot; --post-hook &amp;quot;service nginx start&amp;quot;&amp;#039; &amp;gt;certbot-auto-renew-cron&lt;br /&gt;
crontab certbot-auto-renew-cron&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
maybe mar  2024 &lt;br /&gt;
&lt;br /&gt;
记得先关ng 不然就kill &lt;br /&gt;
/usr/bin/certbot renew --force-renewal&lt;br /&gt;
restart docker &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
说明 &lt;br /&gt;
--pre-hook 这个参数表示执行更新操作之前要做的事情，因为我有 --standalone 模式的证书，所以需要 停止 nginx 服务，解除端口占用。&lt;br /&gt;
--post-hook 这个参数表示执行更新操作完成后要做的事情，这里就恢复 nginx 服务的启用&lt;br /&gt;
&lt;br /&gt;
https://certbot.eff.org/#freebsd-nginx&lt;br /&gt;
https://my.oschina.net/u/2328699/blog/829503&lt;br /&gt;
&lt;br /&gt;
==第一==&lt;br /&gt;
===单域名===&lt;br /&gt;
 &amp;lt;pre&amp;gt; &lt;br /&gt;
#这是老办法了&lt;br /&gt;
 git clone https://github.com/letsencrypt/letsencrypt&lt;br /&gt;
 cd letsencrypt&lt;br /&gt;
 ./letsencrypt-auto certonly --standalone --email evan886@gmail.com -d linuxchina.net  -d www.linuxchina.net  --debug &amp;lt;/pre&amp;gt;&lt;br /&gt;
===泛域名===&lt;br /&gt;
&amp;lt;pre&amp;gt;#泛域名 注xxx.com请根据自己的域名自行更改  要续期的话，执行certbot-auto renew就可以了&lt;br /&gt;
./certbot-auto --server https://acme-v02.api.letsencrypt.org/directory  --email evan886@gmail.com -d &amp;quot;*.linuxchina.net&amp;quot; --manual --preferred-challenges dns-01 certonly&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====泛域名申请参考====&lt;br /&gt;
[https://my.oschina.net/kimver/blog/1634575#comment-list 申请Let&amp;#039;s Encrypt通配符HTTPS证书]&lt;br /&gt;
&lt;br /&gt;
[https://segmentfault.com/a/1190000015354547 Let&amp;#039;s Encrypt 泛域名证书申请及配置]&lt;br /&gt;
&lt;br /&gt;
[https://www.v2ex.com/t/438200 Let&amp;#039;s Encrypt 泛域名证书签发成功啦]&lt;br /&gt;
&lt;br /&gt;
[http://diamondfsd.com/lets-encrytp-hand-https/ Let&amp;#039;s Encrypt 使用教程，免费的SSL证书]&lt;br /&gt;
&lt;br /&gt;
[https://www.xiaoz.me/archives/10050 使用acme.sh脚本申请Let’s Encrypt 泛域名SSL证书]&lt;br /&gt;
&lt;br /&gt;
==第二、Let’s Encrypt免费SSL证书获取与应用==&lt;br /&gt;
&amp;lt;pre&amp;gt;在完成Let’s Encrypt证书的生成之后，我们会在”/etc/letsencrypt/live/yourdomain/”域名目录下有4个文件就是生成的密钥证书文件。&amp;lt;br/&amp;gt; cert.pem – Apache服务器端证书&amp;lt;br/&amp;gt; chain.pem – Apache根证书和中继证书&lt;br /&gt;
#我们重点的是关注这个 &lt;br /&gt;
fullchain.pem – Nginx所需要ssl_certificate文件&lt;br /&gt;
privkey.pem – 安全证书KEY文件&lt;br /&gt;
&lt;br /&gt;
ssl_certificate /etc/letsencrypt/live/linuxchina.net/fullchain.pem;&lt;br /&gt;
ssl_certificate_key /etc/letsencrypt/live/linuxchina.net/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
 #90天后自动更新 好像不行，有交互界面的 &lt;br /&gt;
 * * */90 * * /data/mon/autossl&lt;br /&gt;
&lt;br /&gt;
 详细的nginx https配置文件&lt;br /&gt;
 #4 blog &lt;br /&gt;
    server {&lt;br /&gt;
        listen       80;&lt;br /&gt;
       # listen [::]:80 ipv6only=on default_server;&lt;br /&gt;
        listen 443 default ssl;&lt;br /&gt;
       #listen [::]:80;&lt;br /&gt;
       #ssl on;&lt;br /&gt;
        ssl_certificate /etc/letsencrypt/live/linuxchina.net/fullchain.pem;&lt;br /&gt;
        ssl_certificate_key /etc/letsencrypt/live/linuxchina.net/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
       server_name  linuxchina.net www.linuxchina.net;&lt;br /&gt;
&lt;br /&gt;
 #by evan&lt;br /&gt;
    if ($scheme = http) {&lt;br /&gt;
           return 301 https://$server_name$request_uri;&lt;br /&gt;
    } &lt;br /&gt;
 #by evan&lt;br /&gt;
    #    server_name  blog.linuxchina.net;&lt;br /&gt;
        charset utf-8;&lt;br /&gt;
          root /data/www/evan;&lt;br /&gt;
        index index.php index.html index.htm;&lt;br /&gt;
&lt;br /&gt;
注意:&lt;br /&gt;
ssl on 不要打开 ，不然会400&lt;br /&gt;
&lt;br /&gt;
重新更新key  现在可以用更加简单的了 ，见文章最前面&lt;br /&gt;
 #/bin/sh &lt;br /&gt;
 cd /data/www/ssl/letsencrypt&lt;br /&gt;
 #git clone https://github.com/letsencrypt/letsencrypt&lt;br /&gt;
 ./letsencrypt-auto certonly --renew-by-default --email evan886@gmail.com  -d linuxchina.net  -d www.linuxchina.net --debug&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=trouble shooting=&lt;br /&gt;
&amp;lt;pre&amp;gt;IMPORTANT NOTES:&amp;lt;br/&amp;gt; &amp;amp;nbsp;- Congratulations! Your certificate and chain have been saved at&amp;lt;br/&amp;gt; &amp;amp;nbsp; &amp;amp;nbsp;/etc/letsencrypt/live/linuxchina.net-0001/fullchain.pem. Your cert&amp;lt;br/&amp;gt; &amp;amp;nbsp; &amp;amp;nbsp;will expire on 2017-03-13. To obtain a new or tweaked version of&amp;lt;br/&amp;gt; &amp;amp;nbsp; &amp;amp;nbsp;this certificate in the future, simply run letsencrypt-auto again.&amp;lt;br/&amp;gt; &amp;amp;nbsp; &amp;amp;nbsp;To non-interactively renew *all* of your certificates, run&amp;lt;br/&amp;gt; &amp;amp;nbsp; &amp;amp;nbsp;&amp;quot;letsencrypt-auto renew&amp;quot;&amp;lt;br/&amp;gt; &amp;amp;nbsp;- If you like Certbot, please consider supporting our work by:&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;ssl_certificate /etc/letsencrypt/live/linuxchina.net-0001/&amp;lt;br/&amp;gt; &amp;amp;nbsp;ssl_certificate_key /etc/letsencrypt/live/linuxchina.net-0001/ fullchain.pem&amp;amp;nbsp;; &amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
删除原来的再把新生成的复制到原来的位置&amp;lt;br/&amp;gt; cp /etc/letsencrypt/live/linuxchina.net-0001/privkey.pem .&amp;lt;br/&amp;gt; cp /etc/letsencrypt/live/linuxchina.net-0001/fullchain.pem .&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=参考=&lt;br /&gt;
相关参考文档&lt;br /&gt;
&lt;br /&gt;
这个官方的教程比较好 其实&amp;lt;br/&amp;gt; [https://certbot.eff.org/#freebsd-nginx https://certbot.eff.org/#freebsd-nginx]&lt;br /&gt;
&lt;br /&gt;
安装文档&amp;amp;nbsp;&amp;lt;br/&amp;gt; [https://github.com/certbot/certbot https://github.com/certbot/certbot]&lt;br /&gt;
&lt;br /&gt;
[http://stackoverflow.com/questions/8768946/dealing-with-nginx-400-the-plain-http-request-was-sent-to-https-port-error http://stackoverflow.com/questions/8768946/dealing-with-nginx-400-the-plain-http-request-was-sent-to-https-port-error]&lt;br /&gt;
&lt;br /&gt;
实战申请Let’s Encrypt永久免费SSL证书过程教程及常见问题&amp;lt;br/&amp;gt; [http://www.laozuo.org/7676.html http://www.laozuo.org/7676.html]&lt;br /&gt;
&lt;br /&gt;
Let’s Encrypt SSL证书配置&amp;lt;br/&amp;gt; [http://www.jianshu.com/p/eaac0d082ba2# http://www.jianshu.com/p/eaac0d082ba2#]&lt;br /&gt;
&lt;br /&gt;
[https://my.oschina.net/kimver/blog/1634575 申请Let&amp;#039;s Encrypt通配符HTTPS证书]&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Nginx]] [[Category:Freebsd]]&lt;/div&gt;</summary>
		<author><name>Evan</name></author>
	</entry>
</feed>